How can I run multiple applications with multiple domains on nginx?

318 views
Skip to first unread message

Tito Garrido

unread,
Mar 18, 2013, 4:21:25 PM3/18/13
to web...@googlegroups.com
Hi Folks,

I am reading the book section: http://web2py.com/books/default/chapter/29/13#Nginx

But I couldn't figure out how could I setup nginx to serve multiple domains pointing to a different application on the same web2py instance.

Do you have any example?

like:
mydomain1 -> /home/www-data/web2py/applications/myapp1
mydomain2 -> /home/www-data/web2py/applications/myapp2

Thanks,

Tito


--

Linux User #387870
.........____
.... _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:_______

Richard Vézina

unread,
Mar 21, 2013, 11:26:48 AM3/21/13
to web2py-users
It's not specific to web2py, but may help you maybe :


The idea is to create a other server in nginx...

Richard


--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Massimo Di Pierro

unread,
Mar 21, 2013, 12:06:46 PM3/21/13
to web...@googlegroups.com
Yes you can. From the point of nginx treat all domains as one. the use web2py routes.py to map different domains to different apps.

peter

unread,
Mar 23, 2013, 6:01:38 AM3/23/13
to web...@googlegroups.com
Sorry about replying late Tito. I struggled with your problem for quite a while, and here is a solution.

In the web2py folder have a routes.py like this

#!/usr/bin/python
# -*- coding: utf-8 -*-
routes_app=[
                             ('.*://www.site1.com:\w* /$anything','app1'),
    ('.*://site1.com:\w* /$anything','app1'),
                             ('.*://www.site2.com:\w* /$anything','app2'),
    ('.*://site2.com:\w* /$anything','app2')
]

Then in the application folder for app1 have something like

#!/usr/bin/python
# -*- coding: utf-8 -*-
routes_in = ((r'.*://site1.com:\w* /static/$anything', r'/app1/static/$anything'),
(r'.*://site1.com:\w* /$anything', r'/app1/default/$anything'),
(r'.*://www.site1.com:\w* /static/$anything', r'/app1/static/$anything'),
(r'.*://www.site1.com:\w* /$anything', r'/app1/default/$anything'),)
routes_out = (('/app1/default/(?P<any>.*)', '/\g<any>'),)


and similarly for app2

I hope this helps

Peter

Tito Garrido

unread,
May 8, 2013, 10:29:16 AM5/8/13
to web...@googlegroups.com
Hi Peter! It helps a lot! I didn't know that we could have another routes.py inside the application folder, is it described anywhere in the book? Thanks!

Tito


--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

pbreit

unread,
Oct 12, 2017, 7:23:57 PM10/12/17
to web2py-users
Is this the best way to set up multiple domains on one server with Nginx or better to set up nginx "sites-available" etc configs?
Reply all
Reply to author
Forward
0 new messages