靜態(tài)文件在/frontend/webman目錄
webman應(yīng)用監(jiān)聽8080端口
域名:webman.v3.com
例如訪問:http://webman.v3.com/ 實際訪問/frontend/webman/index.html
例如訪問:http://webman.v3.com/api/user/info 訪問webman應(yīng)用User控制器的info方法
問題已解決:
我知道原因了,我用的是手冊里面的nginx代理示例:
upstream webman {
server 127.0.0.1:8787;
keepalive 10240;
}
server {
server_name webman.v3.com;
listen 80;
access_log off;
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename){
proxy_pass http://webman;
}
}
location / {
root /frontend/webman;
}
}
問題就出在這一句:
proxy_pass http://webman;
需要在后面加上斜杠就OK了:
proxy_pass http://webman/;
如果不加就會把/api/帶上,最終url變成http://127.0.0.1:8787/api/
location /api/ {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
root /frontend/webman;
}