在过去的几周里,我一直在尝试在RedhatAmazonEC2实例上部署我制作的Django网站(使用HTTPS everywhere)。我使用nginx和uwsgi部署了这个网站,但是当我尝试输入EC2实例的IP地址时,连接超时了。(我的教授不会使用主机名)
Nginx将成功地将我重定向到https,但我迄今为止所做的任何尝试都将我引向这个可怕的“连接超时,响应时间过长”屏幕。在
我在网上读了很多教程和stackoverflow的帖子,但到目前为止还没有运气。任何帮助都将不胜感激。在
用版本4.8.5 20160623编译的uWSGI 2.0.15-我运行命令(uWSGI--ini/etc/uWSGI/sites/uWSGI-django.ini公司)在
nginx1.12.1-我将其设置为服务(sudo service nginx start)
Python 3.4
Django 2.0.1版
我的amazonec2实例打开了端口80和443。在
我的Nginx配置如下:
events {
worker_connections 1024;
}
http {
# nginx.conf
# Redirects any requests on port 80 (http) to https:
server {
server_name 35.164.X.X;
listen 80 default_server;
rewrite ^ https://35.164.X.X$request_uri? permanent;
access_log /spool/nginx-redirect.log;
error_log /spool/nginx-redirect-error.log;
}
# django pass-thru via uWSGI, only from https requests:
server {
server_name 35.164.X.X;
listen 443 default_server;
ssl on;
ssl_certificate /etc/ssl/certs/evote.crt;
ssl_certificate_key /etc/ssl/private/evote.key;
access_log /spool/nginx-access.log;
error_log /spool/nginx-error.log;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/ec2-user/EVote/EVote.sock;
proxy_set_header X-Forwarded-Proto https;
}
}
}
乌兹基
^{pr2}$我的Django设置包括
# HTTPS settings
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SECURE_SLL_REDIRECT = True
os.environ['wsgi.url_scheme'] = 'https'
WSGI_APPLICATION = 'website.wsgi.application'
谢谢你的阅读。在
--编辑-- 这是我的Nginx重定向日志,其他日志都是空的。(一开始我删除了IP地址)
- - [04/Feb/2018:01:15:38 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:01:16:09 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:01:16:39 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:02:56:03 +0000] "GET / HTTP/1.1" 301 185 "-" "curl/7.40.0"
- - [04/Feb/2018:02:56:20 +0000] "PROPFIND / HTTP/1.1" 301 185 "-" "-"
- - [04/Feb/2018:03:40:00 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:03:50:05 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:04:22:08 +0000] "GET / HTTP/1.1" 301 185 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
- - [04/Feb/2018:05:15:57 +0000] "GET / HTTP/1.0" 301 185 "-" "masscan/1.0 (https://github.com/robertdavidgraham/masscan)"205.251.233.161 - - [04/Feb/2018:05:37:42 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:05:39:48 +0000] "GET / HTTP/1.1" 301 185 "-" "Mozilla/5.0"
- - [04/Feb/2018:05:47:08 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:05:54:22 +0000] "HEAD /phpmyadmin/scripts/setup.php HTTP/1.1" 301 0 "-" "Mozilla/5.0"
- - [04/Feb/2018:06:18:26 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:06:18:35 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:06:19:13 +0000] "POST /adstore/sns HTTP/1.1" 301 185 "-" "Amazon Simple Notification Service Agent"
- - [04/Feb/2018:08:30:31 +0000] "GET /manager/html HTTP/1.1" 301 185 "-" "Mozilla/3.0 (compatible; Indy Library)"
- - [04/Feb/2018:10:47:12 +0000] "GET / HTTP/1.1" 301 185 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0"
- - [04/Feb/2018:11:44:28 +0000] "HEAD / HTTP/1.1" 301 0 "-" "Cloud mapping experiment. Contact research@pdrlabs.net"
目前没有回答
相关问题 更多 >
编程相关推荐