我需要:
site.com.conf
server {
listen 80;
server_name site.com;
location = / {
proxy_pass http://site.github.io;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
location / {
root /site/dist;
try_files $uri /index.html;
}
}
site2.com.conf
server {
listen 80;
server_name site2.com;
proxy_set_header Host site.com;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://127.0.0.1/$request_uri;
}
}
答案 0 :(得分:1)
在http://site2.com的情况下,您最终将使用uri =" /"当你点击site.com,你已经设置代理到site.github.io。
您可能希望代替site2:
location / {
proxy_pass http://127.0.0.1/site2/$request_uri;
}
然后在site.com中:
location ~ ^/site2(.*)$ {
root /site/dist;
try_files $1 /index.html;
}
OR
location /site2 {
rewrite ^/site2(.*)$ $1 break;
root /site/dist;
try_files $uri /index.html;
}