Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fakiolinho/fdcf9b2e37730b5914fe7469f0cfe973 to your computer and use it in GitHub Desktop.
Save fakiolinho/fdcf9b2e37730b5914fe7469f0cfe973 to your computer and use it in GitHub Desktop.
Laravel - php-fpm - nginx - ssl - www to non-www setup
## HTTP Server
server {
listen 80;
server_name www.mydomain.gr;
return 301 http://mydomain.gr$request_uri;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
server_name mydomain.gr;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
## HTTPS Server
server {
listen 80;
server_name mydomain.gr www.mydomain.gr;
return 301 https://mydomain.gr$request_uri;
}
server {
listen 443;
server_name www.mydomain.gr;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/laravel/public;
index index.php index.html index.htm;
ssl on;
ssl_certificate /etc/ssl/mydomain_gr.crt;
ssl_certificate_key /etc/ssl/mydomain_gr.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
return 301 https://mydomain.gr$request_uri;
}
server {
listen 443;
server_name mydomain.gr;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/laravel/public;
index index.php index.html index.htm;
ssl on;
ssl_certificate /etc/ssl/mydomain_gr.crt;
ssl_certificate_key /etc/ssl/mydomain_gr.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment