Django + Wordpress + Nginx反向代理Apache

时间:2020-01-27 13:31:41

标签: django wordpress apache nginx

我有两台机器,其中一台是django(https://orgofoods.com),另一台是wordpress(https://blog.orgofoods.com)。 Django使用nginx,gunicorn运行,并且配置如下所示

upstream app_server {
    server unix:/home/django/gunicorn.socket fail_timeout=0;
}

server {

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name orgofoods.com;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/django_project/django_project/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/django_project/static;
    }

    # Proxy the static assests for the Django Admin panel
    location /static/admin {
        alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
    }
    location /blog {
        proxy_pass  https://blog.orgofoods.com;
    }

    location /blog/wp-content {
        proxy_pass  https://blog.orgofoods.com/wp-content;
    } 
    location /blog/wp-includes {
        proxy_pass https://blog.orgofoods.com/wp-includes;
    }
    location /blog/wp-login.php {
        proxy_pass https://blog.orgofoods.com/wp-login.php; 
    }
    location /blog/wp-admin {
        proxy_pass https://blog.orgofoods.com/wp-admin;
    }

    location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_redirect off;
            proxy_buffering off;

            proxy_pass http://app_server;
    }


    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/orgofoods.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/orgofoods.com/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 = orgofoods.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name orgofoods.com;
    return 404; # managed by Certbot


}

但是当我尝试访问orgofoods.com/blog时,它返回404错误,并且该请求由nginx处理,因为它需要由apache处理,所以任何人都可以对此进行一些了解。

dev tools network screenshot 预先感谢

p.s .:我遵循了本教程(https://jeffreyeverhart.com/2016/12/11/wordpress-nginx-proxy-server-subdomain-subdirectory

0 个答案:

没有答案