【发布时间】:2021-11-08 07:46:13
【问题描述】:
我正在尝试在 nginx conf 中实现类似的东西:
子域
- sub.domain.com -> 服务 html
- sub.domain.com/api -> 代理到端口 3001
- sub.domain.com/viewer -> 提供另一个 html
子域2
- sub2.domain.com -> 代理到端口 3000
唯一不起作用的路径是查看器,我从“位置/”获取html。所有其他配置都运行良好。
我尝试将查看器移到底部,然后移到顶部和中间,不管它不起作用。
我使用 CentOS7。这是服务器中当前的配置:
events {
}
http {
server {
listen 80;
listen [::]:80;
server_name www.sub.domain.com subdomain.com;
location /viewer {
root /opt/viewer/;
try_files $uri /index.html;
index index.html;
}
location / {
root /opt/client-bo/;
try_files $uri /index.html;
index index.html;
}
location /api {
proxy_pass "http://localhost:3001";
}
}
server {
listen 80;
server_name www.sub2.domain.com sub2.domain.com;
listen [::]:80;
location / {
proxy_pass "http://localhost:3000";
}
}
}
谢谢!
【问题讨论】: