我是非常新的django和nginx和尝试主机我的应用程序使用nginx作为服务器。我可以设置前端与域名和80作为端口,但我无法设置后端与域名服务端口8000。但当我使用的IP地址似乎工作正常,但不与域名。我一直在尝试,因为两天,似乎没有工作。任何帮助都将不胜感激。
前端配置
server{
listen 80;
listen [::]:80;
listen 443 ssl;
include snippets/snakeoil.conf;
server_name example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
# reverse proxy for next server
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
后端配置
server {
listen 8000;
server_name example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/backend/lithexBackEnd;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
1条答案
按热度按时间kpbwa7wx1#
也许这很傻,但是你检查过服务器端口了吗?入口规则和你是否被允许通过端口8000访问?