Welcome! Log In Create A New Profile

Advanced

Re: rewrite *.*.com Host to *.com

Tobias Lott
May 06, 2010 03:16PM
On Thu, 6 May 2010 21:34:03 +0300
pablo platt <pablo.platt@gmail.com> wrote:

> Hi
>
> I'm using nginx is a proxy for a long polling application.
> Old browsers have low limits on number of concurrent http requests so
> I'm using arbitrary subdomains for each vhost.
>
> Is it possible to set the Host header to be vhost.example.com when
> the url is something.vhost1.example.com
> without knowing from advanced what 'something' and 'vhost1' are?
>
> I'm currently able to set Host to *.com but I want to strip the first
> part.
>
> server {
> listen 80;
> server_name *.com;
>
> location /test {
> proxy_set_header Host $Host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_pass http://localhost:8000;
> }
> }
>
> Thanks

Hi Pablo

Just some quick thoughts which might work (aka haven't tried)

1. Use 2 server Directives

server {
listen 80;
server_name *.*.com;

location / {
rewrite ^(.*)$ http://yourcomdomain.com permanent;
}
}

server {
listen 80;
server_name *.com;

location /test {
proxy_set_header Host $Host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
}

2. If Regexp are usable in server_name (are they?)

server {
....
server_name $*.com;
....
}

Greetings
Tobias

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite *.*.com Host to *.com

pablo platt May 06, 2010 02:46PM

Re: rewrite *.*.com Host to *.com

Tobias Lott May 06, 2010 03:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 207
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready