Linux · 5月 2, 2022 0

Nginx 反向代理示例

内容纲要
# 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;
    }
}

参考网址
https://developpaper.com/solve-the-problem-of-301-circular-redirection-of-wordpress-under-nginx-reverse-proxy-apache-service/

%d 博主赞过: