Skip to content

Instantly share code, notes, and snippets.

@AttilaSATAN
Created October 18, 2016 09:46
Show Gist options
  • Save AttilaSATAN/b37c82d01ec971c57eaf8fa0723fd414 to your computer and use it in GitHub Desktop.
Save AttilaSATAN/b37c82d01ec971c57eaf8fa0723fd414 to your computer and use it in GitHub Desktop.
For redirecting every request to SSL and WWW. Using php-fpm.
server {
listen 80;
server_name site.com www.site.com;
return 301 https://www.site.com$request_uri;
}
server {
listen 443;
listen [::]:443;
ssl on;
ssl_certificate /etc/ssl/SSL_certificate.crt;
ssl_certificate_key /etc/ssl/SSL_certificate.key;
server_name site.com;
return 301 https://www.site.com$request_uri;
}
server {
listen 443;
listen [::]:443;
ssl on;
ssl_certificate /etc/ssl/SSL_certificate.crt;
ssl_certificate_key /etc/ssl/ahsapatolyesi.key;
server_name site.com www.site.com site.dev;
root /var/www/site.com;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment