实例https://github.com/moajs/moa-frontend/blob/master/config/nginx.example.conf
server {
listen 8000;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location / {
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 Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3010;
proxy_redirect off;
}
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3005;
proxy_redirect off;
}
}
注意