当前位置: 首页 > >

Nginx配置一个域名下绑定多个实例

发布时间:

2019独角兽企业重金招聘Python工程师标准>>>



1、改变有域名的实例的nginx配置


upstream tomcat_mng.local.com {
server 127.0.0.1:8001 weight=10 max_fails=2 fail_timeout=30s;
}

upstream tomcat_admin.baby.com {
server 162.24.214.129:8005 weight=10 max_fails=2 fail_timeout=30s;
server 162.24.214.128:8005 weight=10 max_fails=2 fail_timeout=30s;
}

upstream tomcat_admin.local.com {
server 173.24.212.129:8007 weight=10 max_fails=2 fail_timeout=30s;
}

server
{
listen 80;
server_name mng.test.local mng.test.com;
access_log /export/servers/nginx/logs/mng.local.com/mng.local.com_access.log main;
error_log /export/servers/nginx/logs/mng.local.com/mng.local.com_error.log warn;
chunkin on;
error_page 411 = @my_error;
location @my_error {
chunkin_resume;
}

root /export/App/mng.local.com/;

location / {
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://tomcat_mng.local.com;
expires 0;
}


location /baby/ {
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://tomcat_admin.baby.com;
expires 0;
}

location /child/ {
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://tomcat_admin.local.com;
expires 0;
}

location /logs/ {
autoindex off;
deny all;
}
}

2、设置各个实例的根路径,下面的两个配置在各自的Tomcat目录下的server.xml中配置。





?








转载于:https://my.oschina.net/sxshifeifei/blog/740676



友情链接: