Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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

Posted

We use nginx. One domain is:

 

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.

  • Thanks 1
Posted

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

http://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 :)

Posted
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?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...