All Projects → FranciscoKnebel → nginx-reverseproxy

FranciscoKnebel / nginx-reverseproxy

Licence: MIT license
A simple implementation of a multidomain nginx reverse proxy, using Node apps.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to nginx-reverseproxy

Engintron
Engintron for cPanel/WHM is the easiest way to integrate Nginx on your cPanel/WHM server. Engintron will improve the performance & web serving capacity of your server, while reducing CPU/RAM load at the same time, by installing & configuring the popular Nginx webserver to act as a reverse caching proxy in front of Apache.
Stars: ✭ 587 (+1176.09%)
Mutual labels:  proxy-server, nginx-proxy
LiveProxies
Asynchronous proxy checker
Stars: ✭ 17 (-63.04%)
Mutual labels:  proxy-server
RandomProxyRuby
Tiny Library for get random proxy (free).
Stars: ✭ 16 (-65.22%)
Mutual labels:  proxy-server
centminmod-magento2
Magento 2.2.2 Install Guide For Centmin Mod Nginx LEMP Stacks
Stars: ✭ 16 (-65.22%)
Mutual labels:  nginx-proxy
saml-auth-proxy
Provides a SAML SP authentication proxy for backend web services
Stars: ✭ 38 (-17.39%)
Mutual labels:  proxy-server
Free-Proxy
Hi there will be a lot of proxies here.
Stars: ✭ 135 (+193.48%)
Mutual labels:  proxy-server
yastack
YAStack: User-space network-stack based on DPDK, FreeBSD TCP/IP Stack, EnvoyProxy
Stars: ✭ 90 (+95.65%)
Mutual labels:  proxy-server
microsocks11
A cross-platform SOCKS5 library and server based on the microsocks project.
Stars: ✭ 22 (-52.17%)
Mutual labels:  proxy-server
docker-letsencrypt-django-nginx-proxy-uwsgi-postgres
Docker + Letsencrypt + Django + Nginx-Proxy + uWSGI 教學
Stars: ✭ 26 (-43.48%)
Mutual labels:  nginx-proxy
nginx-config-reverse-proxy
Nginx Configuration for a Secure Reverse Proxy
Stars: ✭ 30 (-34.78%)
Mutual labels:  nginx-proxy
socks5-proxy
Socks5 Proxy with Go Lang. support USER_ID/PASSWORD. able to bypass HTTPS(SNI) censorship
Stars: ✭ 29 (-36.96%)
Mutual labels:  proxy-server
firefox-secure-proxy
Standalone wrapper for Firefox Private Network
Stars: ✭ 15 (-67.39%)
Mutual labels:  proxy-server
docker-eth-dev
Hacking together a containerized environment for Ethereum development with Truffle using Parity
Stars: ✭ 22 (-52.17%)
Mutual labels:  nginx-proxy
nimSocks
A filtering SOCKS proxy server and client library written in nim.
Stars: ✭ 51 (+10.87%)
Mutual labels:  proxy-server
http-knocking
🚪HTTP-Knocking hides a Web server and open it by knocking sequence: Hide Web server until your knocks
Stars: ✭ 28 (-39.13%)
Mutual labels:  proxy-server
docker-proxy-api
Nginx Proxy with Basic auth and SSL for Docker Rest API
Stars: ✭ 16 (-65.22%)
Mutual labels:  nginx-proxy
Prox5
🧮 SOCKS5/4/4a 🌾 validating proxy pool and upstream SOCKS5 server for 🤽 LOLXDsoRANDum connections 🎋
Stars: ✭ 39 (-15.22%)
Mutual labels:  proxy-server
multiarch-letsencrypt-nginx-proxy
nginx-proxy, docker-gen and letsencrypt-nginx-proxy-companion on arm archs
Stars: ✭ 23 (-50%)
Mutual labels:  nginx-proxy
mtproxy
Alpine-based Docker Image for Telegram MTProto Proxy
Stars: ✭ 89 (+93.48%)
Mutual labels:  proxy-server
sparql-proxy
SPARQL-proxy: provides cache, job control, and logging for any SPARQL endpoint
Stars: ✭ 26 (-43.48%)
Mutual labels:  proxy-server

nginx-reverseproxy

A simple reverse proxy for hosting multiple apps on the same server. The proxy listens on port 80 (or 443, if using the HTTP2 implementation) and, depending on the domain provided, redirects the user to a specific port, where one Node app is listening.

This implementation mantains applications independent between themselves, making it so one's bad behaviour won't influence the other. Apps can also be paused, restarted or updated in an independent form. Changes to the proxy server won't affect the application behavior, as it will still stay online even if the server is not reachable.

Usage

  1. Install nginx on your server (examples using apt):
  sudo apt-get install nginx
  1. Edit the default server block configuration file:
  sudo nano /etc/nginx/sites-available/default
  1. Delete everything on the file, and include your new proxy server:
  • If you want the regular HTTP, copy the file nginx/default.
  • Otherwise, if you want the HTTP2 version (recommended), use the file nginx/default-http2. Please view the tutorial to setup HTTPS in the Setting up HTTPS section, as it is needed to run HTTP2.

This example creates proxies for three apps, each running on a different domain (check the value of server_name in each server block), and each running on a different proxy_pass port, where your app will be running.

Make sure each app runs on the same port as the one you choose on the proxy_pass.

  1. Once you are sure your apps are running on the correct ports, restart the nginx service and it should be working as expected:
sudo service nginx restart

Setting up HTTPS

  1. Generate your dhparam.pem file, running in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

Create a SSL certificate using Let's Encrypt

How to create a certificate, complete guide.

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

Using Certbot is easier and simpler to configure https://certbot.eff.org/lets-encrypt/ubuntuartful-nginx.

  1. Pause Nginx:
sudo service nginx stop
  1. Install Certbot
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx 
  1. Create certificate for each site (regular domain and with www):
sudo certbot --nginx
  1. Follow the steps on the screen. Certbot is a smart bot :)

  2. Restart Nginx and everything should be working:

sudo service nginx restart

6.1 To renew the certificates manually

sudo certbot renew --dry-run

6.2 To renew automatically

sudo crontab -e

Insert the next two lines.

30 2 * * 1 /usr/bin/certbot renew --dry-run
35 2 * * 1 /bin/systemctl reload nginx

To test your nginx configuration, you can use the following:

sudo nginx -t

This wil check your configuration for correct syntax and then try to open files referred in configuration.


Extra
  • To make it so the user can't access your app ports directly (example1.com:8001), you need to add a hostname to your app.listen instruction. That way, the proxy will be the only one who can access those ports, so it can redirect to the user.
var listener = app.listen(port, 'localhost', function() {
    console.log("Listening on port " + listener.address().port);
});
Original question can be found at DigitalOcean.

License

MIT License. Click here for more information.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].