Answer the question
In order to leave comments, you need to log in
Implementation: nginx + gunicorn + django. How to remove a redirect from domain to domain?
Good afternoon. I deal with dzhanga and try to roll out the project to production. I use nginx + gunicorn.
The essence of the problem. Two domains are delegated to the server: t-wave.ru and dragonesis.xyz. When visiting t-wave.ru, everything seems to be fine. But dragonesis.xyz somehow redirects to t-wave.ru
Configs for nginx in the sites-available
t-wave.ru folder
server {
listen 80;
server_name www.t-wave.ru;
rewrite ^/(.*) http://t-wave.ru/$1 permanent;
}
server {
listen 80;
server_name t-wave.ru;
keepalive_timeout 3;
access_log off;
error_log /opt/myenv/log/nginx_error.log crit;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias /opt/myenv/myproject/static/;
expires 3d;
}
location /media/ {
alias /opt/myenv/myproject/media/;
expires 3d;
}
location ~* \.(7z|jpg|jpeg|gif|png|ico|css|bmp|swf|js|html|txt|doc|docx|pdf|rar|xls|xlsx|zip)$ {
root /opt/myenv/myproject/;
expires 3d;
add_header Cache-Control: public;
access_log off;
error_log /opt/myenv/log/nginx_static_error.log;
}
}
server {
listen 80;
server_name www.dragonesis.xyz;
rewrite ^/(.*) http://dragonesis.xyz/$1 permanent;
}
server {
listen 80;
server_name dragonesis.xyz;
keepalive_timeout 3;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias /opt/dragonesis.xyz/static/;
expires 3d;
}
location /media/ {
alias /opt/dragonesis.xyz/media/;
expires 3d;
}
location ~* \.(7z|jpg|jpeg|gif|png|ico|css|bmp|swf|js|html|txt|doc|docx|pdf|rar|xls|xlsx|zip)$ {
root /opt/dragonesis.xyz/;
expires 3d;
add_header Cache-Control: public;
access_log off;
error_log /opt/dragonesis.xyz/log/nginx_static_error.log;
}
}
[program:myproject]
command=/opt/myenv/bin/gunicorn myproject.wsgi:application -c /opt/myenv/myproject/myproject/gunicorn.conf.py
umask=022
autostart=true
autorestart=true
startsecs=10
startretries=3
exitcodes=0,2
stopsignal=TERM
stopwaitsecs=10
user=nobody
bind = '127.0.0.1:8000'
workers = 3
user = "nobody"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question