Converting subdomain to path component without redirect ?

henrique matias hems.inlet at gmail.com
Sun May 5 23:14:37 UTC 2013


Hello Francis, thanks a lot for your help and words.

Sorry if at some point i didn't make something clear.



Starting from scratch,

1. My backend already works, http://my_ip/#{language_code}/anything will
bring "anything" translated to the specified language.

2. Changing the line 40 on my config: http://pastebin.com/bZZA30zC from
proxy_pass http://app_server;
to
proxy_pass http://app_server/de/;

brings me the error: Starting nginx: nginx: [emerg] "proxy_pass" cannot
have URI part in location given by regular expression, or inside named
location, or inside "if" statement, or inside "limit_except" block in
/etc/nginx/nginx.conf:121
nginx: configuration file /etc/nginx/nginx.conf test failed


Regarding: http://nginx.org/r/map :
Sounds like the way to go in order to map domian/subsomains to values ( :

Regarding: http://nginx.org/r/proxy_pass


I tried using the "unix:socket" format, in my case:

proxy_pass http://unix:/tmp/.sock:/it/

as the example in the page you sent, and got the same error.



Thanks a lot for your tips, it definitely helped me to understand it better.


So far the best solution i can see is using map in order to map the
addresses to "language codes", and then execute the rewrite.



peace

On 5 May 2013 09:16, Francis Daly <francis at daoine.org> wrote:

> On Sun, May 05, 2013 at 02:38:17AM +0100, henrique matias wrote:
>
> Hi there,
>
> > Also i tried adding the address to the try_files:
> >
> > try_files $uri $uri @app/de/; and try_files $uri $uri @app/de;
> >
> > but that didn't work either.
>
> Unless you also added new named locations like "@app/de/", I'd expect
> that to return HTTP 500.
>
> That's a more specific problem report than "didn't work".
>
> > The core basic of my problem is  "Rewrite the URL based on the "server
> > name"".
> >
> > So far the only options i see on nginx are:
> >
> > 1. Have a configuration with one "if" and one "rewrite" in order to map
> > server name to path
>
> http://nginx.org/r/map
>
> Set a (possibly empty) variable called (say) $path_prefix, and then use
> that in your rewrite or proxy_pass line.
>
> Note that using a variable in proxy_pass has other requirements too:
>
> http://nginx.org/r/proxy_pass
>
> > 2. Multiple server declarations sharing the same configuration ( probably
> > using some sort of include? )
>
> Can work, if the shared configuration is truly the same.
>
> > What you reckon? Any suggestion ?
>
> I still think that until you demonstrate that your back-end works with
> this, the rest is not useful.
>
> Test one thing at a time, and keep the configuration simple.
>
>         f
> --
> Francis Daly        francis at daoine.org
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130506/a72fc0c3/attachment.html>


More information about the nginx mailing list