0
我試圖用nginx/gunicorn瀏覽到我的Django站點上託管的EC2實例。我打開了正確的端口(8000)並綁定了IP地址(0:8000)。只有當我登錄到EC2實例時,纔可以在終端中使用lynx導航到該站點。我無法使用dns:port瀏覽到該網站。這可能是virtualenv的問題嗎?無法使用nginx/gunicorn連接到EC2實例上的Django
我跑ps -ef | grep的nginx的,以確保nginx的正在運行和收到此:
root 4860 1 0 17:36 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 4862 4860 0 17:36 ? 00:00:00 nginx: worker process
ec2-user 4930 4529 0 17:44 pts/2 00:00:00 grep nginx
爲了進一步增加混亂,我是能夠連接到使用Apache服務器前幾天的網站。但是,我沒有使用virtualenv。
nginx.conf:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location/{
proxy_pass http://0.0.0.0:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
它只是掛起。通過端口80上的瀏覽器導航到站點顯示nginx頁面,指示服務器設置正確。 –
奇怪的是,我幾小時前嘗試導航到網站。等待它加載大約5分鐘後,我只是厭倦了,關閉了我的筆記本電腦。幾小時後我打開它,發現該網站已經加載,但我無法再連接 –
因此,它聽起來像「gunicorn正常工作」(即,您可以從本地盒子連接到8000端口的獨角獸)和「 nginx正在運行並且可以訪問「(即,您可以通過80端口連接互聯網)。而且他們之間有一些嚴重的,奇怪的延遲。 –