晨风

-------------------- 业精于勤,荒于嬉;行成于思,毁于随

导航

Nginx同一个端口代理前后端

Posted on 2023-09-13 14:36  shenyixin  阅读(275)  评论(0编辑  收藏  举报
    server {
        listen       8080;
        server_name localhost;

        location / {
            proxy_pass http://192.168.9.163:8899;
        }
        location /api/ {
            rewrite           ^/api/(.*)$ /$1 break;
            proxy_pass        http://192.168.9.163:8888;
            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   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }