How to configure nginx as a reverse proxy
Install Nginx
sudo apt install nginx -y
unlink default config file
sudo unlink /etc/nginx/sites-enabled/default
create new config file
sudo vim /etc/nginx/sites-available/reverse-proxy
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
link and activate the new config file
sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/
test and restart
sudo nginx -t
sudo systemctl restart nginx
Configure firewall
sudo ufw allow 'Nginx Full'