我正在通过django发送带有提交组件的表单,此表单在后台执行查询并返回包含一些数据的新页面。在POST请求中,页面被刷新,字段被清除,并且我没有重定向到结果页面。问题是:它可以在runserver和EC2 Windows实例(也可以在runserver)上本地运行,但是当我将项目设置为使用反向代理(apache2)在EC2 Linux计算机上运行时,我会遇到此问题。
以下是我的设置的一些详细信息:
myproject.conf
位于etc/apache2/sites-available/
<VirtualHost *:80>
ServerName 127.0.0.1
ServerAlias localhost
Alias /static /home/project/myproject/static
<Directory /home/project/myproject/>
Order deny,allow
Allow from all
</Directory>
<Directory /home/project/myproject/mysite/>
<Files wsgi.py>
Require all granted
</Files>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
DocumentRoot /home/project/myproject
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/custom.log combined
</VirtualHost>
WSGIScriptAlias / /home/project/myproject/mysite/wsgi.py
WSGIPythonHome /home/project/env
WSGIPythonPath /home/project/myproject
我的Django wsgi.py
文件位置:
home
|_project
|_myproject
|_mysite
| |_wsgi.py
|_manage.py
.
.
.
Apache custom.log
:
(env) ubuntu@ip-10-0-0-231:/home$ sudo tail /var/log/apache2/custom.log
54.207.33.42 - - [22/Aug/2019:19:23:40 +0000] "GET /product/fast_appraisal/result/ HTTP/1.1" 302 304 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
54.207.33.42 - - [22/Aug/2019:19:23:40 +0000] "GET /login?next=/product/fast_appraisal/result/ HTTP/1.1" 301 274 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
54.207.33.42 - - [22/Aug/2019:19:23:40 +0000] "GET /login/?next=/product/fast_appraisal/result/ HTTP/1.1" 200 16351 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:23:40 +0000] "POST /product/fast_appraisal/result/ HTTP/1.1" 200 5001 "http://avaliei.net/product/fast_appraisal/search/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:24 +0000] "GET / HTTP/1.1" 200 3720 "http://avaliei.net/product/fast_appraisal/result/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:26 +0000] "GET /product/laudo HTTP/1.1" 301 244 "http://avaliei.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:26 +0000] "GET /product/laudo/ HTTP/1.1" 200 4190 "http://avaliei.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:29 +0000] "GET /css/searchicon.png HTTP/1.1" 404 14985 "http://avaliei.net/product/laudo/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:30 +0000] "GET /product/fast_appraisal/search/ HTTP/1.1" 200 5012 "http://avaliei.net/product/laudo/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
200.185.66.155 - - [22/Aug/2019:19:47:50 +0000] "POST /product/fast_appraisal/result/ HTTP/1.1" 200 5002 "http://avaliei.net/product/fast_appraisal/search/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
在POST上,我应该看到“结果”页面,但没有重定向,并且字段也已清理。
Apache error.log
文件上没有任何内容。
我已经尝试过其他nginx/gunicorn
之类的反向代理,但是遇到相同的问题或超时错误。数据库连接和所有其他AWS设置一切正常。我还有其他网站部分可与后台查询配合使用。问题仅在此特定页面中。
我没有错误消息。我是否缺少myproject.conf
上的某些配置行?知道为什么只有在使用反向代理运行时我的请求才能正常工作吗?
希望很清楚可以理解。
谢谢。