nginx2_scheduling
クライアント172.18.123.28ngx
プロキシサーバーとしてのnginxサーバー:
[root@centos87/etc/nginx/conf.d] #cat vhosts.conf
server {
listen 80 default_server;
root / data / website1;
server_name www.a.com www.google.com;
access_log / var / log / nginx /a.com.access.log圧縮;
listen 443 ssl;
ssl_certificate /etc/nginx/conf.d/a.com.crt;
ssl_certificate_key /etc/nginx/conf.d/a.com.key ;
ssl_session_cache shared:sslcache:20m;
ssl_session_timeout 10m;
location / {
proxy_pass http://192.168.137.97/;
}
バックエンドサーバーとしてのhttpd:
yum install httpd
echo rs97> index.html
テスト1:[root @ client〜] #curl 172.18.123.29
rs97
テストフェーズ2:バックエンドサーバーポートを変更します:8080
[root @ client〜] #curl 172.18.123.29
<html>
<head> <title> 502 Bad Gateway </ title> </ head>バックエンドメッセージの疑似応答
テストフェーズ3:nginxはproxy_passを変更しますnginxリスニングポート:8080
場所/ {
proxy_pass http://192.168.137.97:8080/ ;
}
[root @ client〜] #curl 172.18.123.29
rs97
五试阶段4:iptables -A INPUT -p tcp --dport 8080 -j DROP
[root @ client〜] #curl 172.18.123.29
<html>
<head> <title> 504ゲートウェイタイムアウト</ title> </ head >超時;
五试阶段5:systemctl stop httpd
[root @ client〜] #curl 172.18.123.29
<html>
<head> <title> 502 Bad Gateway </ title> </ head>
五试阶段6:iptables -A INPUT -p tcp --dport 8080 -j REJECT
[root @ client〜] #curl 172.18.123.29
<html>
<head> <title> 502 Bad Gateway </ title> </ head>
テストフェーズ7:結論:
検証:192.168.31.17のルートディレクトリにアクセスするためのproxy_passとスラッシュ; // bbsの
場所/ bbs {
proxy_pass http://192.168.31.17/
}
とスラッシュ:
[root @ client〜] #curl -L 172.18.123.29 / bbs
Rs97
スラッシュの
場所がない場合/ bbs {
proxy_pass http://192.168.31.17
}
[root @ centos17 / var / www / html / bbs] #echo bbs> index.html
test:
[root @ client〜] #curl 172.18.123.29 / bbs /
bbs
検証:192.168.31.17のルートディレクトリにアクセスするためのproxy_passとスラッシュ; // bbsの
場所/ bbs {
proxy_pass http://192.168.31.17/
}
とスラッシュ:
[root @ client〜] #curl -L 172.18.123.29 / bbs
Rs97
スラッシュの
場所がない場合/ bbs {
proxy_pass http://192.168.31.17
}
[root @ centos17 / var / www / html / bbs] #echo bbs> index.html
test:
[root @ client〜] #curl 172.18.123.29 / bbs /
bbs
⯕7:增加セントス7π静分分離テキストhtml
[root @ centos17 / var / www / html] #echo rs97 a.txt> a.txt
[root @ centos17 / var / www / html] #echo rs97 b.txt> b.txt
[root @ centos17 / var / www / html] #echo rs97 a.html> a.html
[root @ centos17 / var / www / html] #echo rs97 b.html> b.html
centos6
[root @ centos6 / var / www / html] #echo rs6 a.txt> a.txt
[root @ centos6 / var / www / html] #echo rs6 b.txt> b.txt
[root @ centos6 / var / www / html]# echo rs6 b.html> b.html
[root @ centos6 / var / www / html] #echo rs6 a.html> a.html
nginx修改:
[root@centos87/etc/nginx/conf.d] #cat vhosts.conf
server {
listen 80 default_server;
ルート/ data / website1;
server_name www.a.com www.google.com;
access_log / var / log / nginx / a.com.access.log圧縮;
listen 443 ssl;
ssl_certificate /etc/nginx/conf.d/a.com.crt;
ssl_certificate_key /etc/nginx/conf.d/a.com.key ;
ssl_session_cache shared:sslcache:20m;
ssl_session_timeout 10m;
location ~ \.html$ {
proxy_pass http://192.168.137.97;
}
location ~ \.txt$ {
proxy_pass http://192.168.137.6;
}
動的および静的分離:
试7:增加セントス7π静分分離テキストhtml
[root @ centos17 / var / www / html] #echo rs97 a.txt> a.txt
[root @ centos17 / var / www / html] #echo rs97 b.txt> b .txt
[root @ centos17 / var / www / html] #echo rs97 a.html> a.html
[root @ centos17 / var / www / html] #echo rs97 b.html> b.html
centos6
[root @ centos6 / var / www / html] #echo rs6 a.txt> a.txt
[root @ centos6 / var / www / html] #echo rs6 b.txt> b.txt
[root @ centos6 / var / www / html] #echo rs6 b.html> b.html
[root @ centos6 / var / www / html] #echo rs6 a.html> a.html
nginx修改:
[root@centos87/etc/nginx/conf.d] #cat vhosts.conf
server {
listen 80 default_server;
ルート/ data / website1;
server_name www.a.com www.google.com;
access_log / var / log / nginx / a.com.access.log圧縮;
listen 443 ssl;
ssl_certificate /etc/nginx/conf.d/a.com.crt;
ssl_certificate_key /etc/nginx/conf.d/a.com.key ;
ssl_session_cache shared:sslcache:20m;
ssl_session_timeout 10m;
location ~ \.html$ {
proxy_pass http://192.168.137.97;
}
location ~ \.txt$ {
proxy_pass http://192.168.137.6;
}
[root @ client〜] #curl -L 172.18.123.2
/ b.html rs97 b.html
[root @ client〜] #curl -L 172.18.123.2
/ a.html rs97 a.html
[root @ client〜] #curl -L 172.18.123.2
/ a.txt rs6 a.txt
[root @ client〜] #curl -L 172.18.123.2
/ b.txt rs6 b.txt
動的および静的分離:
location ~ \.(html|txt|css|jpg)$ {
proxy_pass http://192.168.137.97;
}
location ~ \.php$ {
proxy_pass http://192.168.137.6;
}