![](/img/trans.png)
[英]how to configure nginx to serve specific django url path with another domain
[英]Configure Nginx to serve one endpoint only
我正在使用Flask。
我在www.example.com/上的nginx中配置了我的网站。
现在我的要求是使用不同的域名www.example2.com
为我的应用程序中的一个端点提供服务。
所以可以访问www.example2.com/custom
请注意,我只想为此端点使用www.example2.com域名。 这可能在Nginx中吗?
这是我的Nginx配置供参考。
# the upstream component nginx needs to connect to
upstream flask {
server unix:///home/ubuntu/opt/app/mobifly.sock fail_timeout=0; # for a file socket
}
# configuration of the server
server {
server_name www.example.com www.example2.com;
listen 80;
client_max_body_size 2000M;
proxy_read_timeout 6000;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/project/path/to/project.sock;
}
}
目前我可以使用这两个域访问所有网址,但我想按照上面的指定进行配置。
仅为该server_name
创建另一个服务器块 ,其中一个location
仅匹配/custom
。
server {
server_name www.example.com
...
location / {
...
}
}
server {
server_name www.example2.com
...
location /custom {
...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.