Install nginx as a proxy server for both apache and gun

I have all my code in django, so using gunicorn to host django and using nginx as a reverse proxy. Now I want to host some PHP files in the same domain (or subdomain), using the nginx server as the reverse proxy, and the Apache server.

Can nginx proxy be canceled for two different servers? (if guns fail, try apache)

I can directly host php files in apache, but port 80 is taken by nginx. Suppose I want to host a php blogging application - wordpress on blog.XXXX.com using apache? and my regular site on XXXX.com using nginx and gunicorn

here is the important part of my current nginx.conf

    server {
        listen   80;
        server_name XXXXX.com;
        root /home/ubuntu/code/;

        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_connect_timeout 120;
            proxy_read_timeout 120;
            proxy_pass http://localhost:8000/;
        }
   }
+3
1

, . Apache .

, ( . Unix , /proc/sys/net/ipv4/ip_local_port_range, ipv4, , , Nginx)

Apache:

apache Listen :

Listen 127.0.0.1:<port number that open>// 8080

VirtualHost :

<VirtualHost 127.0.0.1:<port number defined above>>
    config goes here
</VirtualHost>

: .

NGINX:

:

server {
    listen   80;
    server_name XXXXX.com;

#Django app served using Gunicorn
    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 120;
        proxy_read_timeout 120;
        proxy_pass http://localhost:8000/;
    }
#PHP processed by Apache
    location ~ \.php$ {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 120;
        proxy_read_timeout 120;
        proxy_pass http://localhost:<port you configured apache to listen on>/;
    }
}

:

#Server block for Django 
server {
    listen   80;
    server_name XXXXX.com;

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 120;
        proxy_read_timeout 120;
        proxy_pass http://localhost:8000/;
    }
}

#Server block for PHP served using Apache with a subdomain
server {
    listen   80;
    server_name blog.XXXXX.com;

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 120;
        proxy_read_timeout 120;
        proxy_pass http://localhost:<port you configured apache to listen on>/;
    }
}

. root, Gunicorn, Apache ( VirtualHost)

, Apache Nginx, .

0

All Articles