+ Post New Thread
Results 1 to 6 of 6
Web Development Thread, Nginx Reverse Proxy in Coding and Web Development; How do you successfully setup nginx as a reverse proxy. Currently external DNS two domain names ourschool.org and mail.ourschool.org get ...
  1. #1
    clarky2k3's Avatar
    Join Date
    Nov 2007
    Location
    Northumberland
    Posts
    318
    Thank Post
    35
    Thanked 47 Times in 39 Posts
    Rep Power
    25

    Nginx Reverse Proxy

    How do you successfully setup nginx as a reverse proxy. Currently external DNS two domain names ourschool.org and mail.ourschool.org get sent on one external ip address, our firewall then uses port forwarding to forward port 80 to our internal webserver.

    Currently got nginx setup on same box as apache webserver and configured apache to listen on port *:8080, got nginx setup listening on port 80. Edited the /etc/nginx/sites-available/default to use -

    proxy_pass http://127.0.0.1:8080/;

    This should work, shouldnt it or have I missed a trick?

    Thanks

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    We use nginx. One domain is:

    Code:
    server {
        listen          8080;
        server_name     mail.bishopbarrington.net;
    
        include /etc/nginx/httperr.conf;
    
        location / {
            proxy_pass          http://mail.bishopbarrington.net:80/;
            proxy_set_header    Host        $host;
            proxy_set_header    X-Real-IP   $remote_addr;
            proxy_set_header    X-Forwarded-For     $remote_addr;
            proxy_set_header    X-Originating-IP    $remote_addr;
            proxy_set_header    HTTP_REMOTE_ADDR    $remote_addr;
            proxy_set_header    REMOTE_ADDR         $remote_addr;
        }
    }
    You can safely ignore the include line - it just sets up custom error pages for the site. You can also pick and choose which proxy_set_header entries you want. Just add more server{ ... } entries for each site you have.

  3. Thanks to webman from:

    clarky2k3 (3rd December 2009)

  4. #3
    clarky2k3's Avatar
    Join Date
    Nov 2007
    Location
    Northumberland
    Posts
    318
    Thank Post
    35
    Thanked 47 Times in 39 Posts
    Rep Power
    25
    So you dont have any virtual hosts on apache? Currently I dont just listening *:8080

  5. #4
    clarky2k3's Avatar
    Join Date
    Nov 2007
    Location
    Northumberland
    Posts
    318
    Thank Post
    35
    Thanked 47 Times in 39 Posts
    Rep Power
    25
    Just used my brain for once and figured it out, thanks for your help!

  6. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,413
    Thank Post
    642
    Thanked 964 Times in 664 Posts
    Blog Entries
    2
    Rep Power
    327
    Yeah, we still have many sites under Apache using virtual hosts on the same box as Nginx, but also 2-3 different sites on other boxes.

    Here's how it's currently set up:

    • Nginx and Apache run on the same box (bbs-web-002).
    • Nginx runs on port 8080, and only serves the outside world.
    • Port 80 via external IP is forwarded to port 8080 (Nginx) on bbs-web-002.
    • Using hostnames, Nginx proxies the requests to the appropriate place, set ip each server { ... } directive.
    • Bbs-web-002 (and the rest of the LAN) always resolves the internal IP equivalent of all external-facing sites.


    Internal IP examples:

    bbs-web-002: 192.168.0.11
    mail.bishopbarrington.net: 192.168.0.13
    www.bishopbarrington.net: 192.168.0.11 (runs on bbs-web-002)

    What exactly do you want Nginx to do at your end and for which hostnames?

    EDIT Just seen your updated post - no problem

  7. #6
    clarky2k3's Avatar
    Join Date
    Nov 2007
    Location
    Northumberland
    Posts
    318
    Thank Post
    35
    Thanked 47 Times in 39 Posts
    Rep Power
    25
    Right running the website through nginx forwarding to apache, great! If I want to add one for mail.ourserver.org do i put the config in the same file or create a new one?

SHARE:
+ Post New Thread

Similar Threads

  1. RM EasyLink reverse Proxy Solution
    By KWIK in forum Windows
    Replies: 0
    Last Post: 11th March 2008, 03:26 PM
  2. Replies: 0
    Last Post: 2nd November 2007, 09:58 AM
  3. DNS reverse look up zones.
    By Kyle in forum Windows
    Replies: 1
    Last Post: 16th October 2007, 08:42 AM
  4. Reverse Proxy and Moodle
    By wesleyw in forum How do you do....it?
    Replies: 3
    Last Post: 11th June 2007, 01:49 PM
  5. reverse proxy ajax apps
    By CyberNerd in forum Web Development
    Replies: 3
    Last Post: 15th June 2006, 07:32 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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