0

I configured nginx as SSL terminator for varnish according to this guide: https://www.linode.com/docs/websites/varnish/use-varnish-and-nginx-to-serve-wordpress-over-ssl-and-http-on-debian-8/

I need http to https redirection too as i only want my site to be accessible over https.

my nginx website configs:

HTTP config of nginx site:

    server {
listen  8080;
listen  [::]:8080;
server_name  www.arcadesite.io;
return       301 http://arcadesite.io$request_uri;
}
server {
listen 8080;l
listen [::]:8080;
server_name  arcadesite.io;
root /var/www/html;
port_in_redirect off;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
   include fastcgi_params;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_pass unix:/var/run/php7.2-fpm.sock;
   }
error_log /var/www/html/error.log notice;
}

My HTTPS config:

server {
listen  443 ssl;
listen  [::]:443 ssl;
server_name  arcadesite.io;
port_in_redirect off;
ssl                  on;
ssl_certificate /etc/letsencrypt/live/arcadesite.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/arcadesite.io/privkey.pem; # managed by Certbot
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
ssl_prefer_server_ciphers   on;
ssl_session_cache   shared:SSL:20m;
ssl_session_timeout 60m;
add_header Strict-Transport-Security "max-age=31536000";
add_header X-Content-Type-Options nosniff;
location / {
 proxy_pass http://127.0.0.1:80;
 proxy_set_header Host $http_host;
 proxy_set_header X-Forwarded-Host $http_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 https;
 proxy_set_header HTTPS "on";

 access_log /var/www/html/access.log;
 error_log  /var/www/html/error.log notice;
 }
}
server {
listen 8080;
listen [::]:8080;
server_name  arcadesite.io;
root /var/www/html;
index index.php;
port_in_redirect off;
location / {
  try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
   try_files $uri =404;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   include fastcgi_params;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_param HTTPS on;
   fastcgi_pass unix:/var/run/php7.2-fpm.sock;
   }
}

But on visiting my website, it gives me 502 error. Please help

Note: this is NOT a wordpress site

  • 1
    i already answered a same question with that, that vanish wont boost WordPress because nginx can this nativly... please look here serverfault.com/questions/980184/… – djdomi Sep 11 '19 at 5:28
  • Its not with wordpress this time – Rahul Biswas Sep 11 '19 at 5:30
  • 1
    doesnt matter, it enables the caching and https only – djdomi Sep 11 '19 at 5:36
  • okay thanks for the info – Rahul Biswas Sep 11 '19 at 5:44