Proxy Everything into a Linux Container with nginx
I previously wrote about setting up Node.js + Ghost in an Ubuntu LXC container and using Apache to proxy all web requests into that container. This works pretty well for the most part, but it seems like nginx is much better tool for this since it was pretty much designed to be a proxy server. We have a server that we are using for all Bit-Monkeys projects and I recently set up gitlab, along with a development site for openfaqs inside of LXC containers. The main benefit of this approach is that you can isolate the environments, manage upgrades and updates of various pieces separately, and fix issues in one environment without bringing down your entire infrastructure. Setting this up to work with nginx is super easy. First you will need to grab the IP address of your container which you can easily get by running as the root user
lxc-ls --fancy
apt-get install nginx
. The last step is to create a virtual host config file for your container.
vim /etc/nginx/sites-available/yoursite
server {listen 80;
server_name dev.openfaqs.com www.dev.openfaqs.com;
location / {
proxy_pass http://10.0.3.194:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
port_in_redirect off;
proxy_redirect http://10.0.3.194:5000 /;
proxy_connect_timeout 300;
}
}
ln -s /etc/nginx/sites-available/yoursite /etc/nginx/sites-enabled/yoursiteservice nginx restart
Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Now What?
- SQLite DB Migrations with PRAGMA user_version
- Setting up ANTLR4 on Windows
- Dagger Feels Like Magic
- Types and Roles If Not Exists in PostgreSQL
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Useful Bluesky Tools from Robb Knight • Posts • Atom Feed
- Re: Bluesky from Colin Devroe
- From the Red Hell to the Sky of Blue from Straphanger
- We don’t need to use what we make from Derek Sivers blog
- Ubuntu Summit 2024: A joyful experience filled with sorrow from Planet KDE | English
- Sabotage from jwz
- What if My Tribe Is Wrong? from Armin Ronacher's Thoughts and Writings
- It’s the “1998” of the AI Revolution. So Why Can I Safely Ignore It? from The Internet Review
Articles from blogs I follow around the net
[RODEN] Enrique Allen
Roden Readers — The first memory I have of Enrique Allen is from the campus of Stanford. He had just graduated from the d.school and was teaching part-time. We were about to start working together. He was all bounding lightness. That’s the first image: Jum…
via Craig Mod — Writer + Photographer November 21, 202417/11/2024
# Back in May I wrote about being inspired to write a track based on a YouTube comment. I recorded a test not long after and built on that into June. Then the breakdown struck and I had a massive crisis of confidence alongside the depression and anxiety. I …
via Colin Walker - Daily Feed November 21, 2024Cold reading an ADHD affliction
I'm sure there are truly pathological cases of ADHD out there, and maybe taking amphetamines really is a magic pill for some folks. But there clearly is also an entire cottage industry cropping up around convincing perfectly normal people that they …
via David Heinemeier Hansson November 20, 2024Generated by openring