Nginx – Reverse proxy – HTTP/HTTPS

I started a vitalization project of my home server and after that I needed a reverse
proxy server to handle the requests to my backend servers.
I have done some
reading about the different proxy servers and was actually hoping that Squid
would be the end candidate for this, but i discovered squid had a higher CPU usage
vs performance.
Acutally Apache should be the best regarding to this slide
but I have seen that the combination of Apache and Nginx should give a really good
resolut if Nginx is configured to served static cache.

One of the great thing with an reverse proxy server is that you can have multiple
backend servers going out on the same ports and you can have all of your SSL

  • certificates in one place.

    I have forged a http and https configuration file to make it easier to setup a reverse proxy in
    nginx. I have saved mine as ProxyHTTP and ProxyHTTPS so there is going to be
    two files, one for HTTP and one for HTTPS.

    You will only have to change the following lines to make the reverse proxy server working

    server_name example.com;
    ssl_certificate /etc/nginx/ssl/yourcertificate.crt;
    ssl_certificate_key /etc/nginx/ssl/yourcertificate.key;
    ssl_trusted_certificate /etc/nginx/ssl/yourcertificate.pem;
    proxy_pass http(s)://LocalIP;

    you should place the files in

    /etc/nginx/sites-available

    apache have the a2ensite but in nginx we have to do it a little
    different, but still simple
    sudo ln -s /etc/nginx/sites-available/reverseproxy /etc/nginx/sites-enabled/reverseproxy