Last active
March 28, 2023 07:25
-
-
Save taufiqpsumarna/781209f3a86deaf4b4ebfa0146d12c46 to your computer and use it in GitHub Desktop.
Setup Nginx Reverse Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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