fipa
August 2, 2010, 6:11pm
1
Hi,
I have various applications running RoR. In order to improve code
maintenability I have decided to use a single blog application that will
be used by different apps.
So a user will be browsing app1 at: app1.com
And when he wants to check out the blog of app1 he goes to:
app1.com/blog which behind the scene transfer the request to my blog
engine.
I tried the following:
server {
…
location ^~ /blog/ {
proxy_set_header Host $http_host;
proxy_pass http://blog$uri ;
}
}
But it seems to ∞ly redirect the request.
Thanks for your upload
fipa
August 2, 2010, 9:10pm
2
Why in hell does it insist on redirecting?
location /blog/ {
rewrite /blog/(.+) $1 break;
proxy_pass http://blog ;
}
I never understood how nginx handled rewrites.
fipa
August 2, 2010, 9:14pm
3
Fernando P. wrote:
Why in hell does it insist on redirecting?
location /blog/ {
rewrite /blog/(.+) $1 break;
proxy_pass http://blog ;
}
I never understood how nginx handled rewrites.
My bad, it was my trialing slash rewriter that was conflicting. But now
how to handle the trialing slash issue? Just deal with it and hope no
one links to my apps with/without trialing slashes?
fipa
August 2, 2010, 10:01pm
4
Sorry for the typos, trialing should read trailing.
Here is the complete thing for those interested, your mileage may vary
depending how you want the backend app to handle /blog/uri or just /uri
location ^~ /blog/ {
rewrite /blog/(.+) $1 break;
proxy_set_header Host $http_host;
root /optional/root;
proxy_pass http://127.0.0.1:3000/$1 ;
}
fipa
August 2, 2010, 10:05pm
5
On Mon, Aug 02, 2010 at 10:01:26PM +0200, Fernando P. wrote:
}
location ^~ /blog/ {
proxy_pass http://127.0.0.1:3000/ ;
proxy_set_header Host $http_host;
}
–
Igor S.
http://sysoev.ru/en/
fipa
August 3, 2010, 8:45pm
6
How to intercept blog.*?
I tried setting server_name blog.* but it doesn’t seem to work.
fipa
August 3, 2010, 8:34pm
7
Argh! In practice it doesn’t work, as the urls generated by Rails are
incorrect. Therefore I need to use subdomains: blog.* => proxy_pass
I’ll see what I can come up with.
fipa
August 3, 2010, 8:50pm
8
On Tue, Aug 03, 2010 at 08:45:54PM +0200, Fernando P. wrote:
How to intercept blog.*?
I tried setting server_name blog.* but it doesn’t seem to work.
server {
server_name blog.*;
location / {
proxy_pass http://127.0.0.1:3000 ;
proxy_set_header Host $host;
}
}
–
Igor S.
http://sysoev.ru/en/
fipa
August 5, 2010, 11:03am
9
Any reason why server_name blog.; works on my dev machine by only
catching http://blog . and totally fails on my server by catching
everything?
fipa
August 5, 2010, 11:33am
10
Fernando P. wrote:
Any reason why server_name blog.; works on my dev machine by only
catching http://blog . and totally fails on my server by catching
everything?
Update: by setting listen 80 default; to my server that should be
catching all that wasn’t catched previously it appears that server_name
blog.*; isn’t catching anything at all.
fipa
August 3, 2010, 9:17pm
11
I tried setting server_name blog.* but it doesn’t seem to work.
server {
server_name blog.*;
location / {
proxy_pass http://127.0.0.1:3000 ;
proxy_set_header Host $host;
}
}
My bad, it does work. Thank you Igor.
fipa
August 5, 2010, 11:37am
12
What the duck?
I switched to Safari, and it works. I was using Firefox, why wouldn’t it
work previously? Is there some caching going on? That’s pita.
fipa
August 5, 2010, 1:47pm
13
I restarted Firefox and I still can’t access my app at
http://blog.example.com
fipa
August 5, 2010, 2:03pm
14
On Thu, Aug 05, 2010 at 01:51:26PM +0200, Fernando P. wrote:
Ok so for some obscure reason, I had to clear my history in Firefox to
make things work.
I still don’t understand why that would perturb Nginx in detecting the
blog’s subdomain.
Sorry, we can diagnose a problem using debug/error log.
We can not diagnose a “it does not work” problem.
–
Igor S.
http://sysoev.ru/en/
fipa
August 5, 2010, 1:51pm
15
Ok so for some obscure reason, I had to clear my history in Firefox to
make things work.
I still don’t understand why that would perturb Nginx in detecting the
blog’s subdomain.
fipa
August 5, 2010, 6:38pm
16
On Thu, Aug 05, 2010 at 06:31:10PM +0200, Fernando P. wrote:
Sorry, we can diagnose a problem using debug/error log.
We can not diagnose a “it does not work” problem.
What should I be looking for? Specific headers that Firefox was sending?
http://nginx.org/en/docs/debugging_log.html
–
Igor S.
http://sysoev.ru/en/
fipa
August 5, 2010, 6:31pm
17
Sorry, we can diagnose a problem using debug/error log.
We can not diagnose a “it does not work” problem.
What should I be looking for? Specific headers that Firefox was sending?