Skip to content

Instantly share code, notes, and snippets.

@taufiqpsumarna
Last active March 28, 2023 07:25
Show Gist options
  • Save taufiqpsumarna/781209f3a86deaf4b4ebfa0146d12c46 to your computer and use it in GitHub Desktop.
Save taufiqpsumarna/781209f3a86deaf4b4ebfa0146d12c46 to your computer and use it in GitHub Desktop.
Setup Nginx Reverse Proxy
## Nginx Installation
sudo apt-get update
sudo apt-get install nginx
## Create nginx conf (/etc/nginx/sites-available/..)
### Config_option_2
server {
listen 80;
server_name example.com; #change app url
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080; #change app port
}
}
### Config_option_2
server{
listen 80;
server_name example.com; #change app url
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080; #change app port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# location /overview {
# proxy_pass http://127.0.0.1:8080$request_uri;
# proxy_redirect off;
# }
}
}
## Symlink
sudo ln -s /etc/nginx/sites-available/<conf_name> /etc/nginx/sites-enabled/
#source:
https://fedingo.com/how-to-use-nginx-as-reverse-proxy-for-nodejs/
https://blog.logrocket.com/how-to-run-a-node-js-server-with-nginx/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment