最详细nginx反向代理之端口配置

2022-08-09 15:29:51 浏览数 (1)

cd /etc/nginx/

vim nginx.conf

server { listen 80 default_server; listen [::]:80 default_server; server_name 域名; listen 443 ssl; root /usr/share/nginx/html; ssl_certificate cert/1_www.maomin.club_bundle.crt; ssl_certificate_key cert/2_www.maomin.club.key; ssl_session_timeout 5m; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf;

代码语言:javascript复制
   location / {
            root /root/www/;
            index index.html index.htm;
    }
    location /chat/ {
    proxy_pass http://内网:3001/;
    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;
    }
    location /upload/ {
    proxy_pass http://内网:8083/;
    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;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
    }
1234567891011121314151617181920212223242526

更多请见:https://blog.csdn.net/weixin_44519496/article/details/120182160

0 人点赞