If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

I wanted to have the following result

www.myhost.org -> 127.0.0.1:8000/myapp

www.otherhost.org -> 127.0.0.1:8000/otherapp

to achieve this enable the following modules in /etc/lighttpd/lighttpd.conf

server.modules = (
        ...
        "mod_proxy",
        "mod_rewrite",
        ...

now create a virtual host with (also in lighttpd.conf)

$HTTP["host"] =~ "(^|\.)myhost\.org$" {
url.rewrite-once = ( "^/(.*)$" => "/myapp/$1")
proxy.server = (
        "/" => (
                "backend" => (
                        "host" => "127.0.0.1",
                        "port" => 8000,
                )
        )
)
}

go to your web2py root directory and edit routes.py

routes_out = (
('/myapp/(?P<any>.*)', '/\g<any>'),
)

you need to do this for every app in this case I did it for myapp , mostlikely this can be improved,

restart lighttpd and start web2py as usual

I hope I did not forget anything, if so please tell me and I will improve it here

Related slices

Comments (0)


Hosting graciously provided by:
Python Anywhere