我正在尝试使用NGINX-gunicorn-Djngo部署我的webapp。问题是当我在浏览器中打开根URL(例如www.xyz.com)时它显示NGINX的默认欢迎页面但是我想要服务我的使用proxy_pass通过django索引页面。
当我打开www.xyz.com时,它工作正常,因为网址与位置块匹配“/”。请告诉我如何让nginx将www.xyz.com重定向到我的gunicorn服务器。
在下面找到我的nginx.conf
user ec2-user;
worker_processes auto;
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;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65;
types_hash_max_size 2048;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream agencyhunt_server {
server unix:/home/ec2-user/xyz/xyz.sock; fail_timeout=10s;
}
server {
listen 80;
server_name www.taskuse.com;
client_max_body_size 4G;
access_log /home/ec2-user/agencyhunt/logs/nginx-access.log;
error_log /home/ec2-user/agencyhunt/logs/nginx-error.log warn;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unix:/home/ec2-user/xyz/xyz.sock;
}
error_page 404 /404.html;
location = /40x.html {
}
}