LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-24-2015, 08:21 AM   #1
linson_85
Member
 
Registered: Oct 2008
Location: Latitude= 9.9722, Longitude= 76.378
Distribution: Open VZ,fedora & Centos
Posts: 47

Rep: Reputation: 0
Nginx Load Balancer + Reverse Proxy


Hello,

I'm trying to implement Nginx Load Balancer + Reverse Proxy setup.

Heres the scenario.


I have two upstream servers ( running tomcat on port 8080 ) which is running an API application. Also I have some static files associated with the application.

I'm looking for the following setup.

Host the static files in load balancer itself and forward the other requests to upstream servers.


Static files are stored in /var/www/html/static in load balancer.

And API files are stored in /var/lib/tomcat7/webapps/ folder of respective upstream servers.

Could someone please give me a reference configuration to achieve this setup ?
 
Old 04-27-2015, 05:25 AM   #2
linson_85
Member
 
Registered: Oct 2008
Location: Latitude= 9.9722, Longitude= 76.378
Distribution: Open VZ,fedora & Centos
Posts: 47

Original Poster
Rep: Reputation: 0
Wink

Nevermind. I got it. Solution is like as shown below.

server {
listen 443 ssl;
server_name sdnx.biz;
root /var/www/html/;
location ^~ /static {
alias /var/www/html/static;
}


This will exclude the static files from proxy pass and rest can be forwarded to upstream servers as shown below


location / {
proxy_pass http://nxha-upstreamservers;
proxy_connect_timeout 240;
proxy_send_timeout 240;
proxy_read_timeout 240;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;

}
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NGINX horizontal load balancing and vertical reverse proxy. thorwald_hallwardsson Linux - Server 1 05-02-2015 06:38 AM
Nginx Reverse proxy on a internal apache reverse server ITiger Linux - Software 0 04-25-2014 07:44 AM
Load Balancer using Apache Reverse Proxy sarthak.limbachia Linux - Newbie 1 12-14-2012 01:13 PM
nginx load balancer mkiler Linux - Server 1 05-10-2009 08:07 AM
nginx load balancer use real ip? VanDaMe Linux - Software 0 09-19-2008 12:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration