我有一种情况,我想代理将/
块传递给另一个本地进程并尝试/app
路由的文件。
正在发生的事情是只调用/并且完全跳过此/app
。
root /home/ubuntu/frontend/html/public;
location /app {
try_files $uri /index.html;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://171.11.33.222;
}
答案 0 :(得分:0)
我最终使用了多条路径,因为我找不到任何解决方案。
如果有人找到更好的答案,请指导我。
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
root /home/ubuntu/frontend/app/public;
index index.html index.htm;
# Make site accessible from domain
server_name www.domain.com;
if ($ssl_protocol = "") {
rewrite ^ https://$host$request_uri? permanent;
}
# goes to my default application folder
# anything that starts with 'app'
location /app {
try_files $uri /index.html;
}
# everything below goes to my local server
location = / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
location /assets {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
location /blog {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
# anything that starts with '2' like wordpress posts
location ^~ /2 {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
location /home {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
location /about-us {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
# anything that starts with 'wp' like wordpress admin
location ^~ /wp {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
# anything other static urls
location ~ ^/(terms-conditions|kyc-aml|privacy-policy) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_pass http://172.31.33.222;
}
}