Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Nginx and seeother() with relative path #72

Closed
karguine opened this Issue · 2 comments

3 participants

@karguine

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):
            web.seeother('/static/test.txt')

    if __name__ == "__main__": app.run()

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
same.

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/hello.py -a 127.0.0.1 -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;
            fastcgi_pass 127.0.0.1:9002;
            }
            location /static/ {
                if (-f $request_filename) {
                    rewrite ^/static/(.*)$ /static/$1 break;
                }
            }
        }
    }
@anandology
Collaborator

Try adding REAL_SCRIPT_NAME to the environment before spawning the fastcgi.

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

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.