diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/README.md" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/README.md" new file mode 100644 index 0000000000000000000000000000000000000000..151c3be8b93c19c7736b2574e157d09ab4352227 --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/README.md" @@ -0,0 +1,249 @@ +### 安装NGINX Plus + + +请参考NGINX Plus安装手册安装两台NGINX Plus(plus1和plus2) [https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-plus/](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-plus/)。
+plus1的ens33 ip为10.1.20.241,plus2的ens33 ip为10.1.20.242。
+ +### 配置NGINX Plus HA + +在两台NGINX Plus上分别运行nginx-ha-setup命令:
+ + **plus1:** +``` +[root@plus1 /root]$nginx-ha-setup +Thank you for using NGINX Plus! + +This script is intended for use with RHEL/CentOS/SLES/Debian/Ubuntu-based systems. +It will configure highly available NGINX Plus environment in Active/Passive pair. + +NOTE: you will need the following in order to continue: + - 2 running systems (nodes) with static IP addresses + - one free IP address to use as Cluster IP endpoint + +It is strongly recommended to run this script simultaneously on both nodes, +e.g. use two terminal windows and switch between them step by step. + +It is recommended to run this script under screen(1) in order to allow +installation process to continue in case of unexpected session disconnect. + +Press to continue... + +Step 1: configuring internal management IP addresses. + +In order to communicate with each other, both nodes must have at least one IP address. + +The guessed primary IP of this node is: 10.1.20.241/24 + +Do you want to use this address for internal cluster communication? (y/n) +IP address of this host is set to: 10.1.20.241/24 +Primary network interface: ens33 + +Now please enter IP address of a second node: 10.1.20.242 +You entered: 10.1.20.242 +Is it correct? (y/n) +IP address of the second node is set to: 10.1.20.242 + +Press to continue... + +Step 2: creating keepalived configuration + +Now you have to choose cluster IP address. +This address will be used as en entry point to all your cluster resources. +The chosen address must not be one already associated with a physical node. + +Enter cluster IP address: 10.1.20.240 +You entered: 10.1.20.240 +Is it correct? (y/n) + +You must choose which node should have the MASTER role in this cluster. + +Please choose what the current node role is: +1) MASTER +2) BACKUP + +(on the second node you should choose the opposite variant) + +Press 1 or 2. +This is the MASTER node. + +Step 3: starting keepalived + +keepalived is already running. + +Press to continue... + +Step 4: configuring cluster + +Enabling keepalived and nginx at boot time... +注意:正在将请求转发到“systemctl enable nginx.service”。 +注意:正在将请求转发到“systemctl enable keepalived.service”。 +Initial configuration complete! + +keepalived logs are written to syslog and located here: +/var/log/messages + +Further configuration may be required according to your needs +and environment. +Main configuration file for keepalived can be found at: + /etc/keepalived/keepalived.conf + +To control keepalived, use 'service keepalived' command: + service keepalived status + +keepalived documentation can be found at: +http://www.keepalived.org/ + +NGINX-HA-keepalived documentation can be found at: +/usr/share/doc/nginx-ha-keepalived/README + +Thank you for using NGINX Plus! + +[root@plus1 /root]$ +``` + **plus2:** + +``` +[root@plus2 /etc/keepalived]$nginx-ha-setup +Thank you for using NGINX Plus! + +This script is intended for use with RHEL/CentOS/SLES/Debian/Ubuntu-based systems. +It will configure highly available NGINX Plus environment in Active/Passive pair. + +NOTE: you will need the following in order to continue: + - 2 running systems (nodes) with static IP addresses + - one free IP address to use as Cluster IP endpoint + +It is strongly recommended to run this script simultaneously on both nodes, +e.g. use two terminal windows and switch between them step by step. + +It is recommended to run this script under screen(1) in order to allow +installation process to continue in case of unexpected session disconnect. + +Press to continue... + +Step 1: configuring internal management IP addresses. + +In order to communicate with each other, both nodes must have at least one IP address. + +The guessed primary IP of this node is: 10.1.20.242/24 + +Do you want to use this address for internal cluster communication? (y/n) +IP address of this host is set to: 10.1.20.242/24 +Primary network interface: ens33 + +Now please enter IP address of a second node: 10.1.20.241 +You entered: 10.1.20.241 +Is it correct? (y/n) +IP address of the second node is set to: 10.1.20.241 + +Press to continue... + +Step 2: creating keepalived configuration + +Now you have to choose cluster IP address. +This address will be used as en entry point to all your cluster resources. +The chosen address must not be one already associated with a physical node. + +Enter cluster IP address: 10.1.20.240 +You entered: 10.1.20.240 +Is it correct? (y/n) + +You must choose which node should have the MASTER role in this cluster. + +Please choose what the current node role is: +1) MASTER +2) BACKUP + +(on the second node you should choose the opposite variant) + +Press 1 or 2. +This is the BACKUP node. + +Step 3: starting keepalived + +keepalived is already running. + +Press to continue... + +Step 4: configuring cluster + +Enabling keepalived and nginx at boot time... +注意:正在将请求转发到“systemctl enable nginx.service”。 +注意:正在将请求转发到“systemctl enable keepalived.service”。 +Initial configuration complete! + +keepalived logs are written to syslog and located here: +/var/log/messages + +Further configuration may be required according to your needs +and environment. +Main configuration file for keepalived can be found at: + /etc/keepalived/keepalived.conf + +To control keepalived, use 'service keepalived' command: + service keepalived status + +keepalived documentation can be found at: +http://www.keepalived.org/ + +NGINX-HA-keepalived documentation can be found at: +/usr/share/doc/nginx-ha-keepalived/README + +Thank you for using NGINX Plus! + +[root@plus2 /etc/keepalived]$ +``` +### 验证HA主备: + +``` +[root@plus1 /root]$ip add show ens33 +2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 00:0c:29:51:b4:62 brd ff:ff:ff:ff:ff:ff + inet 10.1.20.241/24 brd 10.1.20.255 scope global noprefixroute ens33 + valid_lft forever preferred_lft forever + inet 10.1.20.240/32 scope global ens33 + valid_lft forever preferred_lft forever + inet6 fe80::20c:29ff:fe51:b462/64 scope link + valid_lft forever preferred_lft forever +``` + +``` +[root@plus2 /etc/keepalived]$ip add show ens33 +2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 00:0c:29:dc:fd:f4 brd ff:ff:ff:ff:ff:ff + inet 10.1.20.242/24 brd 10.1.20.255 scope global noprefixroute ens33 + valid_lft forever preferred_lft forever + inet6 fe80::20c:29ff:fedc:fdf4/64 scope link + valid_lft forever preferred_lft forever +[root@plus2 /etc/keepalived]$ +``` + + +``` +[root@plus1 /root]$tcpdump -i ens33 vrrp -n +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes +13:07:10.922791 IP 10.1.20.241 > 10.1.20.242: VRRPv3, Advertisement, vrid 51, prio 201, intvl 100cs, length 12 +13:07:11.924698 IP 10.1.20.241 > 10.1.20.242: VRRPv3, Advertisement, vrid 51, prio 201, intvl 100cs, length 12 +13:07:12.925605 IP 10.1.20.241 > 10.1.20.242: VRRPv3, Advertisement, vrid 51, prio 201, intvl 100cs, length 12 +``` + + +### plus1切换到plus2: + **在plus1:** + +``` +[root@plus1 /root]$touch /var/run/keepalived-manual-failover +``` + **验证:** + +``` +[root@plus1 /root]$tcpdump -i ens33 vrrp -n +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes +13:13:18.584760 IP 10.1.20.242 > 10.1.20.241: VRRPv3, Advertisement, vrid 51, prio 200, intvl 100cs, length 12 +13:13:19.586413 IP 10.1.20.242 > 10.1.20.241: VRRPv3, Advertisement, vrid 51, prio 200, intvl 100cs, length 12 +``` +### 再从plus2切换到plus1 +可以在plus2上 touch /var/run/keepalived-manual-failover 文件, +或是在plus1上删除/var/run/keepalived-manual-failover 文件。 \ No newline at end of file diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus1/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus1/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus1/keepalived.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus1/keepalived.conf" new file mode 100644 index 0000000000000000000000000000000000000000..2f0a777e5e7ca11d5a55f2d4e18a9cd43d46544c --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus1/keepalived.conf" @@ -0,0 +1,37 @@ +global_defs { + vrrp_version 3 +} + +vrrp_script chk_manual_failover { + script "/usr/libexec/keepalived/nginx-ha-manual-failover" + interval 10 + weight 50 +} + +vrrp_script chk_nginx_service { + script "/usr/libexec/keepalived/nginx-ha-check" + interval 3 + weight 50 +} + +vrrp_instance VI_1 { + interface ens33 + priority 101 + virtual_router_id 51 + advert_int 1 + accept + garp_master_refresh 5 + garp_master_refresh_repeat 1 + unicast_src_ip 10.1.20.241/24 + unicast_peer { + 10.1.20.242 + } + virtual_ipaddress { + 10.1.20.240 + } + track_script { + chk_nginx_service + chk_manual_failover + } + notify "/usr/libexec/keepalived/nginx-ha-notify" +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus2/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus2/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus2/keepalived.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus2/keepalived.conf" new file mode 100644 index 0000000000000000000000000000000000000000..727ff1d67a8cf2b52e2455779a111be5caf8786a --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for HA\345\210\207\346\215\242\346\216\247\345\210\266/plus2/keepalived.conf" @@ -0,0 +1,37 @@ +global_defs { + vrrp_version 3 +} + +vrrp_script chk_manual_failover { + script "/usr/libexec/keepalived/nginx-ha-manual-failover" + interval 10 + weight 50 +} + +vrrp_script chk_nginx_service { + script "/usr/libexec/keepalived/nginx-ha-check" + interval 3 + weight 50 +} + +vrrp_instance VI_1 { + interface ens33 + priority 100 + virtual_router_id 51 + advert_int 1 + accept + garp_master_refresh 5 + garp_master_refresh_repeat 1 + unicast_src_ip 10.1.20.242/24 + unicast_peer { + 10.1.20.241 + } + virtual_ipaddress { + 10.1.20.240 + } + track_script { + chk_nginx_service + chk_manual_failover + } + notify "/usr/libexec/keepalived/nginx-ha-notify" +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/README.md" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/README.md" new file mode 100644 index 0000000000000000000000000000000000000000..f3f2854904ba6fb996520388d10c5d3d952c344a --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/README.md" @@ -0,0 +1,68 @@ +### 安装nginxoss1和nginxoss2 +请参考 [Setting Up an NGINX Demo Environment](https://docs.nginx.com/nginx/deployment-guides/setting-up-nginx-demo-environment/)安装好nginxoss1和nginxoss2作为/application1和/application2 服务器,同时安装好plus1作为前端NGINX。 + +### 配置plus1,为相应的url打开debug,而且输出文件输出到不同的error_log文件: +配置/application1,日志文件输出到/var/log/nginx/application1.log,level为debug: +``` +location /application1 { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://app1/; + error_log /var/log/nginx/application1.log debug; + } +``` +配置/application2,日志文件输出到/var/log/nginx/application2.log,level为debug: + +``` +location /application2 { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://app2/; + error_log /var/log/nginx/application2.log debug; + } +``` +### 停止用nginx进程,以nginx-debug启动 + +``` +[root@plus1 /etc/nginx/conf.d]$systemctl stop nginx & systemctl start nginx-debug +[1] 42327 +[1]+ 完成 systemctl stop nginx +[root@plus1 /etc/nginx/conf.d]$ +``` +检查nginx-debug进程运行情况: + +``` +root@plus1 /etc/nginx/conf.d]$systemctl status nginx-debug +● nginx-debug.service - NGINX Plus - high performance web server + Loaded: loaded (/usr/lib/systemd/system/nginx-debug.service; disabled; vendor preset: disabled) + Active: active (running) since 日 2021-10-03 18:26:14 HKT; 33s ago + Docs: https://www.nginx.com/resources/ + Process: 42351 ExecStart=/usr/sbin/nginx-debug -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) + Process: 42339 ExecStartPre=/usr/libexec/nginx-plus/check-subscription (code=exited, status=0/SUCCESS) + Main PID: 42353 (nginx-debug) + CGroup: /system.slice/nginx-debug.service + ├─42353 nginx: master process /usr/sbin/nginx-debug -c /etc/nginx/nginx.conf + └─42354 nginx: worker process + +10月 03 18:26:14 plus1 systemd[1]: Starting NGINX Plus - high performance web server... +10月 03 18:26:14 plus1 nginx-debug[42351]: nginx: [warn] 65535 worker_connections exceed open file resource limit: 1024 +10月 03 18:26:14 plus1 systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start. +10月 03 18:26:14 plus1 systemd[1]: Started NGINX Plus - high performance web server.``` + +``` +### 检查debug输出: +在浏览器上分别输入: +``` +http://10.1.20.241/application1 + +http://10.1.20.241/application2 +``` +在plus1上运行 + +``` +tail -f /var/log/nginx/application1 + +tail -f /var/log/nginx/application2 + +``` +可以查看到相应的debug日志输出 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/app.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/app.conf" new file mode 100644 index 0000000000000000000000000000000000000000..58ba8b70a485c6f7a776540a5757f2dc0d084b3a --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/app.conf" @@ -0,0 +1,21 @@ +server { + listen 80 default_server; + server_name app_server; + + root /usr/share/nginx/html; + error_log /var/log/nginx/app-server-error.log notice; + index demo-index.html index.html; + expires -1; + + sub_filter_once off; + sub_filter 'server_hostname' '$hostname'; + sub_filter 'server_address' '$server_addr:$server_port'; + sub_filter 'server_url' '$request_uri'; + sub_filter 'remote_addr' '$remote_addr:$remote_port'; + sub_filter 'server_date' '$time_local'; + sub_filter 'client_browser' '$http_user_agent'; + sub_filter 'request_id' '$request_id'; + sub_filter 'nginx_version' '$nginx_version'; + sub_filter 'document_root' '$document_root'; + sub_filter 'proxied_for_ip' '$http_x_forwarded_for'; +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/demo-index.html" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/demo-index.html" new file mode 100644 index 0000000000000000000000000000000000000000..6710b9ee1566961da67d429bae4d440bec2300ad --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/demo-index.html" @@ -0,0 +1,103 @@ + + + + Hello World - App 1 + + + + + + + + NGINX Logo +
+

Server name: server_hostname

+

Server address: server_address

+

User Agent: client_browser

+

URI: server_url

+

Doc Root: document_root

+

Date: server_date

+

NGINX Frontend Load Balancer IP: remote_addr

+

Client IP: proxied_for_ip

+

NGINX Version: nginx_version

+
+
+ Auto Refresh +
+ + + diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/nginx.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/nginx.conf" new file mode 100644 index 0000000000000000000000000000000000000000..4ae5010c7ff28228c53678793c18f422bf5027dd --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss1/nginx.conf" @@ -0,0 +1,30 @@ + +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log; +# pid /run/nginx.pid; + +include /usr/share/nginx/modules/*.conf; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 4096; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + include /etc/nginx/conf.d/*.conf; +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/app.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/app.conf" new file mode 100644 index 0000000000000000000000000000000000000000..8e0d57e68f72c4c3bb4394fc24e97d0127e15247 --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/app.conf" @@ -0,0 +1,21 @@ +server { + listen 80 default_server; + server_name app_server; + + root /usr/local/nginx/html; + error_log /var/log/nginx/app-server-error.log notice; + index demo-index.html index.html; + expires -1; + + sub_filter_once off; + sub_filter 'server_hostname' '$hostname'; + sub_filter 'server_address' '$server_addr:$server_port'; + sub_filter 'server_url' '$request_uri'; + sub_filter 'remote_addr' '$remote_addr:$remote_port'; + sub_filter 'server_date' '$time_local'; + sub_filter 'client_browser' '$http_user_agent'; + sub_filter 'request_id' '$request_id'; + sub_filter 'nginx_version' '$nginx_version'; + sub_filter 'document_root' '$document_root'; + sub_filter 'proxied_for_ip' '$http_x_forwarded_for'; +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/demo-index.html" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/demo-index.html" new file mode 100644 index 0000000000000000000000000000000000000000..588b08ec46b43685bb92bac53254c67ff1ace441 --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/demo-index.html" @@ -0,0 +1,103 @@ + + + + Hello World - App 2 + + + + + + + + NGINX Logo +
+

Server name: server_hostname

+

Server address: server_address

+

User Agent: client_browser

+

URI: server_url

+

Doc Root: document_root

+

Date: server_date

+

NGINX Frontend Load Balancer IP: remote_addr

+

Client IP: proxied_for_ip

+

NGINX Version: nginx_version

+
+
+ Auto Refresh +
+ + + diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/nginx.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/nginx.conf" new file mode 100644 index 0000000000000000000000000000000000000000..28b5aa4d40c4a8d7ac747d09fccecdab2e45327d --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/nginxoss2/nginx.conf" @@ -0,0 +1,21 @@ + +#user nobody; +worker_processes 1; + + +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + include /usr/local/nginx/conf/conf.d/*.conf; + + sendfile on; + keepalive_timeout 65; +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/.keep" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/lb.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/lb.conf" new file mode 100644 index 0000000000000000000000000000000000000000..6cfbfabe1fe00e8db90a9fbf6752c67460002d27 --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/lb.conf" @@ -0,0 +1,49 @@ +# in the 'http' context +upstream app1 { + server 192.168.200.15; + # 'server' directives for additional App 1 servers, if using + zone app1 64k; +} + +upstream app2 { + server 192.168.200.16; + # 'server' directives for additional App 2 servers, if using + zone app2 64k; +} + +server { + listen 80; + status_zone backend; + root /usr/share/nginx/html; + + location / { + # directives for serving the site's HTML landing page + } + + location /application1 { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://app1/; + error_log /var/log/nginx/application1.log debug; + } + + location /application2 { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://app2/; + error_log /var/log/nginx/application2.log debug; + } + + location /api { + api write=on; + # directives to control access, such as 'allow' and 'deny' + } + + location = /dashboard.html { + root /usr/share/nginx/html; + } + + location = /status.html { # redirect requests that are made to pre-R14 dashboard + return 301 /dashboard.html; + } +} diff --git "a/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/nginx.conf" "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/nginx.conf" new file mode 100644 index 0000000000000000000000000000000000000000..4ad6dc3a3fb6521b2113ce654f1c2a330ee5c667 --- /dev/null +++ "b/12 \346\227\245\345\270\270\346\216\222\351\224\231\345\217\212case\346\265\201\347\250\213/lab for debug log/plus1/nginx.conf" @@ -0,0 +1,34 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 65535; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr -$proxy_protocol_addr $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; + + +}