如何将 www 更改为 Django url 中的其他内容?
how to change www to something else in Django urls?
我已经为我的 Django 应用程序创建了一个休息 API 但我如何去 api.website.com 而不是 www.website.com/api
顺便说一句,如果这与此有任何关系,我正在使用 nginx
在你的 nginx 配置中添加这样的东西。这会将 api.website.com
上的所有请求传递给你的 gunicorn 套接字 -> 你的 django 应用程序。
server {
listen *:80;
server_name api.website.com;
location ~ ^/api(.*)$ {
try_files $uri /;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://gunicorn_socket/;
}
}
我已经为我的 Django 应用程序创建了一个休息 API 但我如何去 api.website.com 而不是 www.website.com/api
顺便说一句,如果这与此有任何关系,我正在使用 nginx
在你的 nginx 配置中添加这样的东西。这会将 api.website.com
上的所有请求传递给你的 gunicorn 套接字 -> 你的 django 应用程序。
server {
listen *:80;
server_name api.website.com;
location ~ ^/api(.*)$ {
try_files $uri /;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://gunicorn_socket/;
}
}