My website has a rest api (running on port 8080) but I want to redirect it to a https variant. My website should connect to to https and proxy pass it to the rest api on port 8080. It works, sometimes and other times it doesn't work anymore. I'm using pm2 to keep the rest api running.
Which files do you guys need? I'm new to this and I don't know where to seek the error.
# General HTTP to HTTPS with www
server {
listen 80;
listen [::]:80;
server_name example.com default_server;
location / {
return 302 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name example.com default_server;
root /var/www/example.com;
index index.html;
ssl_stapling on;
ssl_stapling_verify on;
ssl_certificate /etc/nginx/ssl/example.com/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location / {
try_files $uri $uri/ /index.html$is_args$args;
}
}
server {
listen 8877 ssl;
listen [::]:8877 ssl;
server_name example.com default_server;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
ssl_stapling on;
ssl_stapling_verify on;
ssl_certificate /etc/nginx/ssl/example.com/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://example.com:8080;
}
}
Aucun commentaire:
Enregistrer un commentaire