admin管理员组文章数量:1202004
I have a Django app on a Hetzner server and a Wordpress site on a Hostinger server.
I want to configure Nginx on my Hetzner server to serve the Django app and when it requests the /route-name
route, it serves a Wordpress site from the Hostinger server.
I've already allowed the IP address of my Hetzner server to access the Wordpress site.
Hetzner server is running Nginx and Hostinger is running Apache2 if that's relevant.
I know there are quite a few questions and answers regarding configuring Nginx to serve Django and Wordpress but I've been scouring this forum and the Internet for several hours now with no solution found for my problem. I suspect it may have to do with my Nginx config, but after trying out several configurations accepted on here and elsewhere, I can't seem to make it work.
This is what I currently have for my Nginx config:
server {
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /var/www/example/static/;
}
location /media/ {
alias /var/www/example/media/;
}
# Reverse proxy for /route-name
location /route-name/ {
proxy_pass http://<IP-ADDRESS OF HOSTINGER SERVER>/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
include proxy_params;
proxy_redirect off;
proxy_pass http://unix:/run/gunicorn.sock;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.example) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name example www.example;
return 404; # managed by Certbot
}
本文标签: How to configure Nginx to serve Django and a Wordpress site on a specific routeStack Overflow
版权声明:本文标题:How to configure Nginx to serve Django and a Wordpress site on a specific route? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738581520a2101192.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论