Last active
January 27, 2020 15:19
-
-
Save meramo/50a9e193ef5e90589a7e to your computer and use it in GitHub Desktop.
Drupal 8 Nginx config
This file contains hidden or 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 { | |
server_name example.com; | |
root /var/www/example; | |
index index.php; | |
error_log /var/www/log/example_error.log; | |
location ~ \..*/.*\.php$ { | |
return 403; | |
} | |
# Block access to hidden directories | |
location ~ (^|/)\. { | |
return 403; | |
} | |
location ~ ^/sites/.*/private/ { | |
return 403; | |
} | |
# No php is touched for static content | |
location / { | |
try_files $uri @rewrite; | |
} | |
# pass the PHP scripts to FastCGI server | |
location ~ \.php$ { | |
fastcgi_index index.php; | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# The address or socket on which FastCGI requests are accepted. Set yours in www.conf | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# Clean URLs | |
location @rewrite { | |
rewrite ^ /index.php; | |
} | |
# Image styles | |
location ~ ^/sites/.*/files/styles/ { | |
try_files $uri @rewrite; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
expires max; | |
log_not_found off; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment