Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

nginx/FastCGI configuration issues

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jester at panix

Feb 15, 2012, 9:02 AM

Post #1 of 4 (374 views)
Permalink
nginx/FastCGI configuration issues

Executive summary: new deployment on nginx 1.0.5 and FastCGI; my
Catalyst apps are in non-root locations. When I go to the base, e.g.
http://mysite.com/incomings, $c->req->uri thinks I'm at
http://mysite.com/incomings//incomings. This is causing problems with
redirects.

I'm in the process of moving a physical server to a VM in EC2, and have
taken the opportunity to move my Cat apps from Apache/mod_perl to
nginx/FastCGI. The latter combination is proving to be vastly faster.
The server is running Ubuntu 11.10, and nginx 1.0.5.

I am having one issue that I can't resolve, however. When I first visit
an app at its root, e.g. http://mysite.com/incomings, I get redirected
over SSH to https://mysite.com/incomings/login. After successful login I
am then returned to http://mysite.com/incomings//incomings. A bunch of
testing and logging has revealed that when I first hit the site,
$c->req->uri thinks that I'm at http://mysite.com/incomings//incomings,
so the redirect is indeed going to where it thinks it originally was.

After this first login, things work fine, so that if I manually go to
http://mysite.com/incomings/ everything ends up OK for continuing use of
the app.

I have a separate nginx configuration file for each Cat app, and they
look more or less like this:

location /incomings {
include fastcgi_params;
fastcgi_param SCRIPT_NAME /incomings/;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass unix:/tmp/incomings.socket;
}

location /incomings/static {
alias /usr/local/www/modules/Incomings/root/static;
}

I tried to follow the docs (at C::M::Deployment::nginx::FastCGI)
exactly, and if I'm doing something wrong, I'm not clear what it is.

I'd be very grateful for any suggestions for how to solve this, as this
is the one thing preventing the server from going live! Thanks.

Jesse Sheidlower

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


lists at eightdegrees

Feb 15, 2012, 11:29 PM

Post #2 of 4 (365 views)
Permalink
Re: nginx/FastCGI configuration issues [In reply to]

On Thu, Feb 16, 2012 at 3:02 AM, Jesse Sheidlower <jester [at] panix> wrote:


> location /incomings {
> include fastcgi_params;
> fastcgi_param SCRIPT_NAME /incomings/;
> fastcgi_param PATH_INFO $fastcgi_script_name;
> fastcgi_pass unix:/tmp/incomings.socket;
> }
>

in those docs they say " if your application is rooted at /myapp".. do they
mean with this..? http://wiki.nginx.org/HttpCoreModule#root


>
> location /incomings/static {
> alias /usr/local/www/modules/Incomings/root/static;
> }
>
> I tried to follow the docs (at C::M::Deployment::nginx::FastCGI)
> exactly, and if I'm doing something wrong, I'm not clear what it is.
>
> I'd be very grateful for any suggestions for how to solve this, as this
> is the one thing preventing the server from going live! Thanks.
>
> Jesse Sheidlower
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>


diment at gmail

Feb 16, 2012, 12:59 PM

Post #3 of 4 (367 views)
Permalink
Re: nginx/FastCGI configuration issues [In reply to]

On 16/02/2012, at 4:02 AM, Jesse Sheidlower wrote:

>
> Executive summary: new deployment on nginx 1.0.5 and FastCGI; my
> Catalyst apps are in non-root locations. When I go to the base, e.g.
> http://mysite.com/incomings, $c->req->uri thinks I'm at
> http://mysite.com/incomings//incomings. This is causing problems with
> redirects.
>
> I'm in the process of moving a physical server to a VM in EC2, and have
> taken the opportunity to move my Cat apps from Apache/mod_perl to
> nginx/FastCGI. The latter combination is proving to be vastly faster.
> The server is running Ubuntu 11.10, and nginx 1.0.5.
>
> I am having one issue that I can't resolve, however. When I first visit
> an app at its root, e.g. http://mysite.com/incomings, I get redirected
> over SSH to https://mysite.com/incomings/login. After successful login I
> am then returned to http://mysite.com/incomings//incomings. A bunch of
> testing and logging has revealed that when I first hit the site,
> $c->req->uri thinks that I'm at http://mysite.com/incomings//incomings,
> so the redirect is indeed going to where it thinks it originally was.


Can you provide a minimal test app? Something that followed the pattern of t/optional-lighttpd|apache*t tests in Catalyst-Runtime would be useful (to polish and fold into Catalyst--Runtime in due course), but not essential. As a minimum, a minimal app exposing the problem with a documented way to run a self-contained nginx/fastcgi instance would be useful.

Having said that I found the following two things about django online that suggest a similar problem over there:

http://serverfault.com/questions/134863/nginx-fastcgi-problems-with-django-double-slashes-in-url
http://stackoverflow.com/questions/4056967/django-double-slash-in-urls-issue-multiple-webservers-apache-and-nginx



_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


jester at panix

Feb 17, 2012, 2:41 AM

Post #4 of 4 (368 views)
Permalink
Re: nginx/FastCGI configuration issues [In reply to]

On Fri, Feb 17, 2012 at 07:59:19AM +1100, Kieren Diment wrote:
>
>
> On 16/02/2012, at 4:02 AM, Jesse Sheidlower wrote:
>
> >
> > Executive summary: new deployment on nginx 1.0.5 and FastCGI; my
> > Catalyst apps are in non-root locations. When I go to the base, e.g.
> > http://mysite.com/incomings, $c->req->uri thinks I'm at
> > http://mysite.com/incomings//incomings. This is causing problems with
> > redirects.
>
> Can you provide a minimal test app? Something that followed the
> pattern of t/optional-lighttpd|apache*t tests in Catalyst-Runtime
> would be useful (to polish and fold into Catalyst--Runtime in due
> course), but not essential. As a minimum, a minimal app exposing the
> problem with a documented way to run a self-contained nginx/fastcgi
> instance would be useful.

Actually this has now been solved: you need to have a trailing slash on
the "location" in the nginx configuration file.

t0m and I have updated the docs accordingly.

Jesse Sheidlower


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.