Nginx to Proxy to your Autoblog/Sites

kblessinggr

PedoBeard
Sep 15, 2008
5,723
80
0
G.R., Michigan
www.kbeezie.com
Nginx as a Proxy to your Blog » KBeezie

Basically a little writeup I did. Something I did for clients a while back, especially when bizops and such were still running rampant. The idea is to have a seperate nginx dedi or VPS (basically most dirt cheap plans would work if you just want to use it as a proxy server)

In a nutshell lets say you have a VPS, and you got 5 blogs on it or wordpress-mu type of set. And you wanted one or more of the domains to appear to be from a different server or even datacenter than the other domains either for SEO purposes or cross-linking purposes. This method would allow you to keep your setup hosted in one place, and you would just add a couple lines to the nginx config and your DNS record to cause the website to appear to be coming from elsewhere. Kinda like how I had client's blogs appearing to be hosted in Panama while the rest of their sites in Texas.

Anywho code sniplets, concerns, and explanations are in the blog post above.
 


Interesting... In your experience, how is the speed? Obviously its slower, but by how much?

When I was doing the Server Pronto box in Panama, to a Server on Softlayer in the Texas Datacenter, the ping thru was under 90ms, basically if he pinged the SL server he'd get around 32-40ms, and to the panama server around 60, and the nginx server pinging the SL server was around 30-40, the hops were pretty lucky in that setup.

It helps if the backend server is a pretty powerful one, but nginx itself can handle simultaneous requests very easily, so obviously the bottle neck is going to be the latency.

In short: It depends on your specific setup and the routes between the two servers.
 
That's pretty cool. I realize the setup would be against the TOS of your hosting service, however would you make yourself available for hire to set something like this up if one had more "tolerant" hosting available?

On the other hand might even be worth getting a VPS on your service just to get a grip on setting up Nginx before attempting something similar elsewhere.
 
That's pretty cool. I realize the setup would be against the TOS of your hosting service, however would you make yourself available for hire to set something like this up if one had more "tolerant" hosting available?

On the other hand might even be worth getting a VPS on your service just to get a grip on setting up Nginx before attempting something similar elsewhere.

True, we don't allow proxies on the VPSes (though this method of proxying is by far the lowest reasource intensive, but setting it up wrong has the potential for abuse). And yes we do have VPS packages where Nginx is pre-configured along with php and mysql 5.1 so that its up and running without much leg work to get started.

On the second note about being available to set it up, as always, between using nginx personally for my own VPS for the last couple years (as such kbeezie.com is run off nginx), and setting up textsfromlastnight.com servers on nginx I do got bit of experience setting it up, and the proxy_pass stuff is the easy stuff by far.
 
Cool stuff :), I use nginx on my pylons deployments and its really solid.

One thing i notice about your config is you didn't use NginxHttpProxyModule

which is good for "X-Forwarded-For"

There was no point in using the variable since it defaults to $remote_addr anyways when there's no X-Forwarded-For header (which would only exist if the proxy server is being proxied from another location as well).

contains client request-header "X-Forwarded-For" with separated by comma $remote_addr. If there is no X-Forwarded-For request-header, than $proxy_add_x_forwarded_for is equal to $remote_addr.