英文:
Nginx default handler
问题
我在配置nginx配置方面遇到了问题。这是我的当前配置:
server {
listen 80;
server_name dev.local sat.local;
location / {
proxy_pass http://sat:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
现在我想要将除了dev.local
和sat.local
之外的所有请求都转发到https://prod:80
,如下所示:
server {
listen 80;
server_name *;
location / {
proxy_pass http://prod:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
我们可以做到吗?以及如何实现这个目标?请帮忙。
英文:
I'm having trouble with configuring the nginx config. Here's my current conf:
server {
listen 80;
server_name dev.local sat.local;
location / {
proxy_pass http://sat:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Now I want all requests to my host other than dev.local
and sat.local
will be passed to https://prod:80
like this
server {
listen 80;
server_name *;
location / {
proxy_pass http://prod:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Can we do it? And how can we do it? Please help.
答案1
得分: 0
已解决,感谢Richard Smith的答案。
server {
listen 80 default_server;
server_name _;
}
英文:
Solved, thanks to Richard Smith's answer.
server {
listen 80 default_server;
server_name _;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论