【发布时间】:2015-12-19 04:04:27
【问题描述】:
在后端使用带有 Gunicorn 的 Django,每次我提交表单并应该发送到 example.com/pagetwo 时,我都会发送到 localhost/pagetwo。
我是 Nginx 的新手,所以如果有人能指出问题所在,我会非常感激 :)
default.conf:
server {
listen 80;
server_name example.com;
location /static/ {
root /srv;
}
location / {
proxy_redirect off;
proxy_pass http://unix:/srv/sockets/website.sock;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
这是来自索引页面的表格:
<form id='formone' method='POST' action=''> {% csrf_token %}
{{ form.as_p }}
<br />
<button type="submit" class="btn btn-success btn-sm">Submit</button>
</form>
【问题讨论】:
-
表单上的操作是否正确?
-
我已经从主页添加了表单标签以供参考
-
我假设您可以通过 get 请求访问 example.com/pagetwo?你在修改你的主机文件吗?
-
您确实假设正确,但看起来 GwynBleidD 以微弱优势击败您回答。不过感谢您的帮助:)
标签: django redirect nginx localhost gunicorn