Nginx server (reverse proxy / web hosting)
Install and configure Nginx as a web server or reverse proxy.
What this tutorial does
The tutorial "Nginx server (reverse proxy / web hosting)" helps you achieve this goal:
Install and configure Nginx as a web server or reverse proxy.
Debian/Ubuntu
-
Install Nginx: apt install -y nginx -
Start and activate: systemctl enable --now nginx - --- Create a virtual host ---
- Create /etc/nginx/sites-available/mysite.conf:
- server {
- listen 80;
- server_name example.com www.example.com;
- root /var/www/monsite;
-
index index.php index.html; - location / { try_files $uri $uri/ =404; }
- }
-
Activate site: ln -s /etc/nginx/sites-available/monsite.conf /etc/nginx/sites-enabled/ - Test the configuration: nginx -t
-
Reload Nginx: systemctl reload nginx - --- Configure as a reverse proxy ---
- In the server block, replace location / with:
-
location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }