Hosting multiple python apps different url mount points
Fri 22 December 2017 by Thejaswi PuthrayaIf you host multiple (virtual hosting) python web apps (django, flask etc) behind nginx on a single server, you have two options:
- Using subdomains
- On different URL mount points
Using subdomains, you will have to update your DNS records for every app that you deploy. While the deployment is cleaner (no sharing of cookies etc), this requires a little more effort to setup.
With the second method ie different URL mounts, you don't have to update any DNS record but there is a chance of cookies getting overwritten if you aren't careful.
The gunicorn server handles multiple URL mount points through the SCRIPT_NAME header set by the reverse proxy (in our case nginx).
Here's an nginx config snippet of hosting two different apps A at /abc/ and B at /def/. So when you visit say /abc/about/ and /def/about/, you are visiting the /about/ URL on the apps A and B respectively.
server { ... location /abc { proxy_pass http://localhost:8001; include proxy_params; proxy_set_header SCRIPT_NAME /abc; } location /def { proxy_pass http://localhost:8002; include proxy_params; proxy_set_header SCRIPT_NAME /def; } }
Elasticsearch autocomplete on related keywords
Recently, I had to work on a client request to add autocomplete to their site's search based not just on a specific list but on related keywords.
For example, suppose you had a list of TV series like Simpsons, Futurama, Tom and Jerry etc. The autosearch had to suggest the …
read moreSimple Command Line Dropbox Uploader in Python
I don't use Dropbox frequently. In fact, I would prefer not to use it but work requires me to use it from time to time. My only use case was to upload files onto a shared folder. So for my usage, it makes no sense to run the desktop client …
read moreChanging fonts for Platypus document templates in reportlab
Learning Python 1
Launch of Safebrowsing-python
Launch of Safebrowsing-python
Today I launched my second project online after django-check-constraints, safebrowsing-python. The project is based on the Google Safebrowsing API. Check out the announcement on the google-safebrowsing-api mailing list and also the usage wiki page at the project home.
Wish you a happy and safe browsing on the …
An Idle Mind is a Devil's Workshop
An idle mind is a devil's workshop
On thursday, my previous semester results were out. I logged on to the site and checked out my result. My result was anything but surprising. Then I thought to myself, "Why not give people the freedom to compare their marks with their peers' …
I blog in ReSt Part 3
I blog in ReSt Part 3
This is the final part in the "I blog in ReSt" series. This part discusses about how to get the templates going for the blog.
- Create a folder called templates in the project directory and add the absolute path to the directory in the …
I blog in ReSt Part 2
I blog in ReSt Part 2
Once done with setting up the project, we need to code our views and templates to complete the blog. This part deals with coding the views for the blog. The different views that we require are
- For displaying the landing page
- For displaying the …
I blog in ReSt Part 1
I blog in ReStructured Text Part-1
Nowadays everyone blogs. Blogs have become the medium for people to express almost everything. So I started blogging in January on Blogger. Initially I was satisfied with it but started feeling cramped for features. Wordpress and PyBlosxom looked like good alternatives but it was …