Skip to content

Instantly share code, notes, and snippets.

@dunderrrrrr
Created February 21, 2020 13:42
Show Gist options
  • Save dunderrrrrr/500ace0d74706b9999c716a436449d64 to your computer and use it in GitHub Desktop.
Save dunderrrrrr/500ace0d74706b9999c716a436449d64 to your computer and use it in GitHub Desktop.
A reverse proxy is an intermediary proxy service which takes a client request, passes it on to one or more servers.

A reverse proxy is an intermediary proxy service which takes a client request, passes it on to one or more servers, and subsequently delivers the server’s response to the client.

Install Nginx

$ sudo apt install nginx

Set up reverse proxy

Let's say you have a service (like a docker container) on port 5000. You want to forward this to domain.com, http.
Then, we need to create a file within the /etc/nginx/sites-available directory that contains the reverse proxy information.

reverse-proxy.conf

server {
    listen 80;
    server_name domain.com www.domain.com;
    location / {
        proxy_pass http://127.0.0.1:5000;
    }
}

Once you’ve added the appropriate directives to your .conf file, activate it by linking to /sites-enabled/ using the following command.

$ ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf

Lastly, run an Nginx configuration test and restart Nginx.

$ service nginx configtest
$ service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment