Reverse Proxy Con Nginx
Ottobre 12, 2021Installare nginx
apt install nginx
systemctl enable nginx
Verificae firewall
ufw status
Configurare certificati
mkdir /etc/nginx/ssl-certs/
nano /etc/nginx/ssl-certs/nginx.crt
incollare il certificato SSL
nano /etc/nginx/ssl-certs/nginx.key
incollare la private key
Configurare nginx
cd /etc/nginx/sites-available/
nano default
server {
listen 80;
listen [::]:80;
server_name mailserver.DOMINIO.it;
return 301 https://mailserver.DOMINIO.it$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name sito.DOMINIO.it;
return 301 https://sito.DOMINIO.it$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name clienti.DOMINIO.it;
return 301 https://clienti.DOMINIO.it$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl-certs/nginx.crt;
ssl_certificate_key /etc/nginx/ssl-certs/nginx.key;
server_name mailserver.DOMINIO.it;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://IP:443/;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl-certs/nginx.crt;
ssl_certificate_key /etc/nginx/ssl-certs/nginx.key;
server_name sito.DOMINIO.it;
location / {
proxy_pass http://IP:8080;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl-certs/nginx.crt;
ssl_certificate_key /etc/nginx/ssl-certs/nginx.key;
server_name clienti.DOMINIO.it;
location / {
proxy_pass http://IP:8080;
}
}