Last active
September 3, 2020 17:31
-
-
Save johanneslamers/f6d2bc0d7435dca130fc to your computer and use it in GitHub Desktop.
Craft CMS Nginx config for Laravel Forge with locale support
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
server { | |
listen 80 default_server; | |
server_name default; | |
root /home/forge/default/public; | |
# FORGE SSL (DO NOT REMOVE!) | |
# ssl on; | |
# ssl_certificate; | |
# ssl_certificate_key; | |
index index.html index.htm index.php; | |
charset utf-8; | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
access_log off; | |
error_log /var/log/nginx/example.com-error.log error; | |
error_page 404 /index.php; | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SERVER_NAME $http_host; | |
} | |
location @rewrites { | |
rewrite ^(.*) /index.php?p=$1 last; | |
} | |
location / { | |
try_files $uri $uri/ @rewrites; | |
} | |
location @enrewrites { | |
rewrite ^/en/(.*)$ /en/index.php?p=$1? last; | |
} | |
location /en/ { | |
try_files $uri $uri/ @enrewrites; | |
} | |
#location ~ ^(.*)$ { | |
# try_files $uri $uri/ /index.php?p=$uri&$args; | |
#} | |
location ~* (?:^|/)\. { | |
deny all; | |
} | |
location ~* (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ { | |
deny all; | |
} | |
location ~* \.(?:manifest|appcache|html?|xml|json)$ { | |
try_files $uri /index.php?$query_string; | |
expires -1; | |
access_log /var/log/nginx/example.com-access.log; | |
} | |
location ~* \.(?:rss|atom)$ { | |
try_files $uri /index.php?$query_string; | |
expires 1h; | |
add_header Cache-Control "public"; | |
} | |
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { | |
try_files $uri /index.php?$query_string; | |
expires 1M; | |
add_header Cache-Control "public"; | |
} | |
location ~* \.(?:css|js)$ { | |
try_files $uri /index.php?$query_string; | |
expires 1y; | |
add_header Cache-Control "public"; | |
} | |
location ~* \.(?:ttf|ttc|otf|eot|woff)$ { | |
try_files $uri /index.php?$query_string; | |
expires 1M; | |
add_header Cache-Control "public"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment