Donnerstag, 13. September 2012

Job of the (to)day

Today i had a lot of fun (!!!!)

I worked with Nginx to establish a fill working redirect and proxy server. There are customers which like the idea of having multiple domains pointing to the same webserver. There are several ways to do this. Mostly used is apache with reddirets or proxy settings. The real way to do it in my eyes is nginx.

So what do you need, lets take a look at basic 301 redirects
server {
server_name test.xadmin.info;
reweite ^ http://example.com;
}

adding this to your default.conf of nginx sets redirecting from test.xadmin.info to example.com. quite easy(!).

UPDATE:
In addition to above you can do "hidden" redirects which dont show the url you refer to. I used to do that via proxy_pass

server {
server_name xadmin.info;
location / {
proxy_pass http://www.example.com;
proxy_redirect off;
proxy_set_header Host www.example.com;
}
}

The above code does that. So any connection to xadmin.info goes directly to www.example.com whitout changing the url bar in your browser.
proxy_set_header Host www.example.com;

Passes the refer url to the other webserver. This is needed if on example.com would run more then one Apache (lighty , whatever) instances. Not passing the Host would let to using the default host on the other side.