Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2013
    Posts
    21
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Configure Nginx as Reverse proxy with Apache in Localhost

    Hi ,
    I am Currently using Apache Server in localhost , now i want to use nginx as reverse proxy with apache .
    For Ex:When a request is come from client side (static) , the request should not go to apache server, it should read from nginx server. When a request is come from client (dynamic) , the request should now go to apache and respond to it.

    1. How should i manage my apache files to get configured with nginx.

    2. How should i configure the nginx to link with apache.

    3. How should i configure the port(8080) to both servers..

    Give some suggestion

  • #2
    New Coder 4B/75/73/41/'s Avatar
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    1
    Thanked 3 Times in 3 Posts
    How to setup NGINX as a proxy for Apache:

    These instructions work for a debian based Linux Distro.

    1 - Install NGINX
    2 - Configure "/etc/nginx/sites-available/whatever"

    Code:
    server {
            listen   80; 
    
            root /var/www/; 
            index index.php index.html index.htm;
    
            server_name example.com; 
    
            location / {
            try_files $uri $uri/ /index.php;
            }
    
            location ~ \.php$ {
            
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8080;
    
             }
    
             location ~ /\.ht {
                    deny all;
            }
    }
    3 - Make Virtual Host

    Code:
    ln -s /etc/nginx/sites-available/whatever /etc/nginx/sites-enabled/whatever
    4 - Remove "/etc/nginx/sites-enabled/default"
    5 - Install Apache
    6 - "/etc/apache2/ports.conf" Should have these lines:

    Code:
    NameVirtualHost 127.0.0.1:8080
    Listen 127.0.0.1:8080
    7 - Make new host.

    Code:
    cp /etc/apache2/sites-available/default /etc/apache2/sites-available/whatever
    Code:
    nano /etc/apache2/sites-available/whatever
    8 - Make sure that the Virtual-Host line looks like this:

    Code:
    <VirtualHost 127.0.0.1:8080>
    9 - Activate it: "a2ensite example"
    10 - Install PHP
    11. - Restart both Apache & NGINX.

    Hope this helps any.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •