Nginx 反向代理示例
Published on Aug. 22, 2023, 12:11 p.m.
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 8001 ;
listen [::]:8001;
# Everything is a 404
# location / {
# return 404;
# }
# location / {
# proxy_pass http://192.168.123.232:8096;
# }
location / {
proxy_pass http://192.168.123.135;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
#Forward host information
proxy_set_header Host $host;
}
# Includes virtual hosts configs.
#include /etc/nginx/http.d/proxy/*.conf;
# You may need this to prevent return 404 recursion.
location = /404.html {
internal;
}
}