I have tried many ways but do not know how to run Django on example.com and wordpress on example.com/blog
The following running pr
As i understand you have a server running your django site and one running your wordpress site. if so you can do something like this:
{
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name example.com;
access_log /var/log/nginx/example-access.log;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /blog/ {
proxy_pass http://127.0.0.1:(wordpress port);
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
if you need to server the php blog from ngix no apache in the middle use somethon like:
location ~ /blog/.*\.php$ {
root /var/www/html/blog;
index index.php index.html index.htm;
set $php_root /var/www/html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}