CNode
查看回复

回复 (3)

Z
zangse#1·9 年前

location ^~ /api/ { root html; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://localhost:8001/api/; proxy_redirect default; } location ^~ /admin_api/ { rewrite ^/admin_api/?$ /api/$1 redirect; root html; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://localhost:8002/api/; proxy_redirect default; } 我这样配置过,一个项目请求了多个后台,然后改api前缀进行区分

R
ResJay#2·9 年前

location / { try_files $uri $uri/ /index.html; }

N
nullcc#3·9 年前

如果你只是原样转发请求的话,可以尝试下面的配置:

location ~* ^(.*) {
    proxy_pass http://127.0.0.1:9000;  # 你要转发的上游服务器
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
}
参与回复
登录后即可参与回复。登录