Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Nginx and seeother() with relative path #72

karguine opened this Issue · 2 comments

3 participants


I have problem with redirection in webpy and nginx. I setted up
nginx-1.0.4 and webpy-0.35 on my FreeBSD 8.0 box (hostname: kappa).

Here is simple script:

    import web
    urls = (
        '/t', 'index',

    app = web.application(urls, globals())

    class index:
        def GET(self):

    if __name__ == "__main__":

If I run script just from command line or using lighttpd, redirect works fine and
getting me in http://kappa/static/test.txt as expected.

If run from from nginx, I have redirect to http://kappa/t/static/test.txt.
No matter if I using rewrite in nginx.conf or no, situation is the

Also redirect works fine if I use full path in seeother() like 'http://kappa/static/test.txt'

webpy application starts with spawn-fcgi (spawn-fcgi -d /usr/local/www/
hello -f /usr/local/www/hello/ -a -p 9002

Here is nginx's config file:

    http {
        include       mime.types;
        default_type  application/octet-stream;
        server {
            listen       80;
            server_name  localhost;
            location / {
            include /usr/local/etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            location /static/ {
                if (-f $request_filename) {
                    rewrite ^/static/(.*)$ /static/$1 break;

Try adding REAL_SCRIPT_NAME to the environment before spawning the fastcgi.

 $ export REAL_SCRIPT_NAME=""
 $ spawn-fcgi ....

That worked, thanks.

@anandology anandology closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.