Project

General

Profile

Deployment with FastCGI giving wrong internal paths

Added by Jake Petroules over 11 years ago

I've deployed my Wt application using lighttpd and FastCGI.

If I navigate to: http://domain.com/, I can browse around, all the paths are correct.

But if I navigate to: http://domain.com/photos, the application then thinks the base is /photos/ instead of /, and my internal paths are all doubled up (i.e.http://domain.com/photos/photos).

My lighttpd .conf file:

var.appdir = "/opt/myapp"

# Map static resource URLs to their physical locations
alias.url = (
    "/favicon.ico" => appdir + "/favicon.ico",
    "/resources" => appdir + "/resources"
)

# Make sure FastCGI requests are only processed for non-static resource URLs
$HTTP["url"] =~ "^(?!/(favicon|resources))" {
    fastcgi.server += (
        "/" => ((
            # httpd will require write access to this directory
            "socket" => "/usr/wt/socket",

            "bin-path" => var.appdir + "/photocrayze",
            "max-procs" => 1,
            "check-local" => "disable",
"docroot" => "/",
            "bin-environment" => (
                "SCRIPT_FILENAME" => "/",
                "LD_LIBRARY_PATH" => var.appdir,
                "WT_APP_ROOT" => var.appdir,
                "WT_CONFIG_XML" => var.appdir + "/wt-config.xml")
        ))
    )
)

How can I fix this so that navigating using the URL bar and navigating internally give the same paths?


Replies (9)

RE: Deployment with FastCGI giving wrong internal paths - Added by Koen Deforche over 11 years ago

Hey Jake,

We got a similar problem a while back --- it has to do with the fact that you are handling "http://domain.com/" by your FastCGI application, which somehow isn't consistent with how the CGI variables (SCRIPT_NAME, ...) are passed on and/or interpreted by Wt.

Can you set the value for the CGI variable SCRIPT_NAME to "/" and see if that helps ?

Regards,

koen

RE: Deployment with FastCGI giving wrong internal paths - Added by Jake Petroules over 11 years ago

Do you know how I would set that in lighttpd?

RE: Deployment with FastCGI giving wrong internal paths - Added by Koen Deforche over 11 years ago

Hey,

I would guess in the same way as you set SCRIPT_FILENAME ?

Regards,

koen

RE: Deployment with FastCGI giving wrong internal paths - Added by Jake Petroules over 11 years ago

I tried that, as well as

server.document-root = "/" and setenv.add-environment = ( "SCRIPT_NAME" => "/" )

no effect.

RE: Deployment with FastCGI giving wrong internal paths - Added by Jake Petroules over 11 years ago

What web server do you use for hosting the official Wt website and how is that one configured?

RE: Deployment with FastCGI giving wrong internal paths - Added by Koen Deforche over 11 years ago

Hey Jake,

We use HAProxy as a reverse proxy to built-in httpd's (which works like a charm !).

Regards,

koen

RE: Deployment with FastCGI giving wrong internal paths - Added by Jake Petroules over 11 years ago

How do you handle stability issues? For example what if the Wt app crashes, do you have something set up so the process gets restarted automatically?

RE: Deployment with FastCGI giving wrong internal paths - Added by Koen Deforche over 11 years ago

Hey Jake,

We use 'monit'. Perhaps better tools exist, and we have not been 100% happy with it: monit sometimes crashes too so ideally you also need to monitor monit :-)

Regards,

koen

RE: Deployment with FastCGI giving wrong internal paths - Added by Marco Gulino about 11 years ago

bump..

I think there's really something wrong with internal paths on fastcgi; I can see the correct path on wApp~~environment().getCgiValue("PATH_INFO"), but wApp~~>internalPath() doesn't match.

    (1-9/9)