nginx proxy文件编写总结
upstream.conf
upstream api {
server 192.168.10.10:8080;
server 192.168.10.20:8080;
}
server{
listen 443 ssl;
server_name gui.sensen.com;
location / {
proxy_pass http://api;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/sensen/acccess.log json;
}
rewrite.conf
server{
listen 443 ssl;
server_name doc.luoluo.com;
location / {
proxy_pass http://192.168.10.10:8080;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/(.*)$ /api/$1 break;
}
location /api {
proxy_pass http://192.168.10.20:8080;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/sensen/doc_acccess.log main;
}
producter.conf
server{
listen 443 ssl;
server_name producter.luoluo.com;
location / {
proxy_pass http://192.168.10.10:9091;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
}
location /pay {
proxy_pass http://192.168.10.20:8080;
proxy_redirect off;
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_set_header X-Forwarded-Proto $scheme;
rewrite ^/pay/(.*)$ /rest/payment/$1 break;
}
location /rest/service/ {
proxy_pass http://192.168.10.30:8080;
proxy_redirect off;
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_set_header X-Forwarded-Proto $scheme;
}
access_log /var/log/nginx/producter/access.log json;
}
normal.conf
server{
listen 443 ssl;
server_name sn.luluo.com;
location / {
proxy_pass http://192.168.10.20:80;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
}
access_log /var/log/nginx/sensen/access.log json;
}