Hi all,
I have managed to answer my own question, through trial and error - but thought I would share the solution for those who are interested: 1. After installing nginx, I replaced the contents of the /etc/nginx/proxy_params file with the following: proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; client_max_body_size 10M; 2. Next, I added a .vhost file for my domain like so: sudo nano /etc/nginx/sites-available/dhmis.org.vhost 3. And inside that file I put the following: server { listen 80; server_name www.dhmis.org dhmis.org; # Proxy pass to servlet container location / { root /home/hisp/tomcat-dhis2-1/webapps/ROOT; proxy_pass http://localhost:8080; include /etc/nginx/proxy_params; } location /staging { root /home/hisp/tomcat-dhis2-2/webapps/staging; proxy_pass http://localhost:8081; include /etc/nginx/proxy_params; } location /training { root /home/hisp/tomcat-dhis2-3/webapps/training; proxy_pass http://localhost:8082; include /etc/nginx/proxy_params; } } Note that the .war files for the three instances are named "ROOT.war", "staging.war" and "training.war" respectively, corresponding to each location above. 4. Next, I linked the file in etc/nginx/sites-enabled with the sites-available folder, like so: cd /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/hisp.org.vhost hisp.org.vhost 5. Next, get rid of the default file in sites-enabled: sudo mv default /home/hisp/default 6. And lastly, restart nginx: sudo /etc/init.d/nginx restart Note: no changes to nginx.conf required. Hope that helps someone out there. Comments, suggestions welcome. Kind regards, Jason Phillips Software & Information Systems Health Information Systems Programme ----------------------------------------------------- Email: <mailto:ja...@hisp.org> ja...@hisp.org Mobile : 072 9737250 Landline: 021 7120170 Fax: 021 7120170 Skype: jason.n.phillips This message may contain privileged and confidential information intended only for the person or entity to which it is addressed. Any review, retransmission, dissemination, copy or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient, is prohibited. If you received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and thereafter delete the material from any computer. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the view of the entity transmitting the message. From: Jason Phillips [mailto:ja...@hisp.org] Sent: 23 March 2014 10:11 AM To: 'dhis2-users@lists.launchpad.net' Subject: nginx Reverse Proxy Config for Dedicated Web Server with multiple instances Hello all, I am trying to set up nginx as a reverse proxy on a dedicated web server with three instances of Tomcat/DHIS2 (connecting to a dedicated Db Server, successfully configured and checked). I have been unable to make nginx behave as required, after numerous different configurations, and hours of trawling the 'Net. Attempting to following the instructions on dhis2.org resulted in bind errors ([emerg] bind() to 0.0.0.0:80 failed (98: address already in use)), and after several variations I tried setting up a simple reverse proxy following the instructions on howtoforge.com at this link <http://www.howtoforge.com/how-to-set-up-nginx-as-a-reverse-proxy-for-apache 2-on-ubuntu-12.04> . I now have arrived at the same place, albeit by a slightly different path, and am getting those bind errors again. I have even shut down all three Tomcats and removed and purged Apache (in case it was somehow interfering, which it apparently is not). The domain dhmis.org has a DNS entry for dhis, za.dhis and train.dhis pointing to the server's IP. My current configuration includes a file in /etc/nginx/site-available called "dhmis.org.vhost", which is linked to the ./sites-enabled folder. Herewith its contents: server { listen 80; server_name www.dhmis.org dhmis.org; # Have put in za.dhis.dhmis.org and variations here. root /home/hisp/tomcat-dhis2-1/webapps/zanat/; # Have tried ROOT here too! # Serve static content location ~ (\.js$|\.css$|\.gif$|\.woff$|\.ttf$|\.eot$|\.ico$|^/images/|^/icons/|^/dhis- web-commons/.*\.png$) { add_header Cache-Control public; expires 7d; } # Proxy pass to servlet container location / { proxy_pass http://localhost:8080/; # Have added 8080/zanat as variations here. include /etc/nginx/proxy_params; } } What am I doing wrong? Kind regards, Jason Phillips Software & Information Systems Health Information Systems Programme ----------------------------------------------------- Email: <mailto:ja...@hisp.org> ja...@hisp.org Mobile : 072 9737250 Landline: 021 7120170 Fax: 021 7120170 Skype: jason.n.phillips This message may contain privileged and confidential information intended only for the person or entity to which it is addressed. Any review, retransmission, dissemination, copy or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient, is prohibited. If you received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and thereafter delete the material from any computer. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the view of the entity transmitting the message. --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
<<image001.png>>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-users Post to : dhis2-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-users More help : https://help.launchpad.net/ListHelp