atom feed18 messages in ru.sysoev.nginxRegular Expression global redirect
FromSent OnAttachments
altiamgeFeb 25, 2012 7:59 pm 
António P. P. AlmeidaFeb 25, 2012 8:40 pm 
Edho AriefFeb 25, 2012 10:09 pm 
Edho AriefFeb 25, 2012 10:19 pm 
altiamgeFeb 25, 2012 11:26 pm 
Edho AriefFeb 25, 2012 11:28 pm 
Mark AlanFeb 26, 2012 4:18 am 
António P. P. AlmeidaFeb 26, 2012 6:38 am 
Edho AriefFeb 26, 2012 6:41 am 
altiamgeFeb 26, 2012 3:38 pm 
António P. P. AlmeidaFeb 26, 2012 4:20 pm 
altiamgeFeb 26, 2012 4:25 pm 
António P. P. AlmeidaFeb 26, 2012 4:40 pm 
altiamgeFeb 26, 2012 5:14 pm 
MaxFeb 26, 2012 10:33 pm 
António P. P. AlmeidaFeb 27, 2012 2:12 am 
MaxFeb 27, 2012 7:46 pm 
António P. P. AlmeidaFeb 28, 2012 4:09 am 
Subject:Regular Expression global redirect
From:altiamge (ngin@nginx.us)
Date:Feb 25, 2012 7:59:08 pm
List:ru.sysoev.nginx

I'm using nginx as a reverse proxy for about 2000 websites. I'm trying to find a good way to redirect all www traffic to nonwww addresses. I don't want to have a separate entry for every domain...just a global redirect in the server block preferably. I found lots of examples to do this one domain at a time, but does anyone have any suggestions on how to do it for the whole server?

I was thinking of extracting the domain something like this then using an if statement, but I understand that if's are not recommended:

server_name ~^(\.)?(?<domain>.+)$;

thanks, altimage

here's my server block:

server { listen 80; server_name _;

location / { proxy_pass http://websites; } }

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,222984,222984#msg-222984