Last active
December 26, 2017 21:15
-
-
Save achmadfatoni/cce27df0e464dc44d60c90072501bb4b to your computer and use it in GitHub Desktop.
letsencrypt laravel configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## http://domain.com and http://www.domain.com redirect to https://www.domain.com | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name domain.com www.domain.com; | |
include /etc/nginx/snippets/letsencrypt.conf; | |
location / { | |
return 301 https://www.domain.com$request_uri; | |
} | |
} | |
## https://domain.com redirects to https://www.domain.com | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name domain.com; | |
ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem; | |
include /etc/nginx/snippets/ssl.conf; | |
location / { | |
return 301 https://www.domain.com$request_uri; | |
} | |
} | |
## Serves https://www.domain.com | |
server { | |
listen 443 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server ipv6only=on; | |
ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem; | |
include /etc/nginx/snippets/ssl.conf; | |
root /var/www/domain/public; | |
index index.php index.html index.htm; | |
# Make site accessible from http://localhost/ | |
server_name www.domain.com; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ /index.php?$query_string; | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php/php7.0-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