我们在 EC2 私有子网的 NGINX 上托管了 Django 应用程序,我们无法通过 AWS 应用程序负载均衡器端点访问它。下面是来自位置的配置文件/etc/nginx/sites-enabled/myserver.conf
我们在配置文件中504 Gateway timeout
使用端口 80,在配置文件502 bad Gateway
中使用 443。
upstream my_server {
#server 0.0.0.0:80;
server unix:/home/ubuntu/Desktop/star/star.sock fail_timeout=0;
}
server {
listen 443; # default_server
server_name 0.0.0.0;
client_max_body_size 4G;
access_log /home/ubuntu/Desktop/star/logs/nginx-access.log;
error_log /home/ubuntu/Desktop/star/logs/nginx-error.log;
location /static/ {
root /home/ubuntu/Desktop/star/dashboard/static/;
}
location / {
proxy_hide_header X-Frame-Options;
include proxy_params;
proxy_pass http://unix:/home/ubuntu/Desktop/star/star.sock;
}
# Error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/ubuntu/Desktop/star/dashboard/static/;
}
location ^~ /(css|js) {
root /home/ubuntu/Desktop/star/dashboard/static/;
}
}
server {
if ($host = 0.0.0.0) {
return 301 https://$host$request_uri;
}
if ($host = 0.0.0.0) {
return 301 https://$host$request_uri;
}
listen 443;
server_name 0.0.0.0;
return 404;
}