-
-
Save antixrist/cf12d6b49367979ef622 to your computer and use it in GitHub Desktop.
nginx "seo-strict" config for MODx Revolution
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 { | |
# ... | |
# ... | |
# merge_slashes off; | |
# } | |
# upstream your-backend {server unix:/var/run/php5-your-backend.sock;} | |
server { | |
server_name i.DOMAIN.TLD; | |
location / { | |
proxy_pass http://DOMAIN.TLD/i/; | |
} | |
} | |
server { | |
listen 80; | |
server_name js.DOMAIN.TLD; | |
location / { | |
proxy_pass http://DOMAIN.TLD/js/; | |
} | |
} | |
server { | |
server_name www.DOMAIN.TLD; | |
return 301 $scheme://DOMAIN.TLD$request_uri; | |
} | |
server { | |
listen 80; | |
server_name *.DOMAIN.TLD DOMAIN.TLD; | |
charset utf-8; | |
root /var/www/yoursite/www; | |
access_log /var/log/nginx/yoursite-access.log; | |
error_log /var/log/nginx/yoursite-error.log; | |
index index.php index.html; | |
rewrite_log on; | |
location ~* ^/(adminka|manager|connectors|connectors-[_A-Z-a-z-0-9]+|_build)/ { | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass your-backend; | |
} | |
break; | |
} | |
# Hide modx /core/ directory | |
location ~* ^/core/ { | |
# deny all; | |
return 404; | |
} | |
# If file and folder not exists --> | |
location / { | |
try_files $uri $uri/ @rewrite; | |
} | |
# Redirect from index.html file to folder name | |
location ~* ^(.*)/index\.html$ { | |
if ($request_uri ~* '^(.*)/index\.html$') { | |
# rewrite ^(.*)/index\.html$ $scheme://$host$1 permanent; | |
rewrite ^(.*)/index\.html$ $scheme://$host$1/ permanent; | |
} | |
} | |
# Redirect from index.php file to folder name | |
location ~* ^(.*)/index\.php$ { | |
if ($request_uri ~* '^(.*)/index\.php$') { | |
# rewrite ^(.*)/index\.php$ $scheme://$host$1 permanent; | |
rewrite ^(.*)/index\.php$ $scheme://$host$1/ permanent; | |
} | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass your-backend; | |
} | |
# Remove double slashes in url. https://modx.pro/help/2386/#comment-69137 | |
location ~ // { | |
rewrite ^(.*)//+(.*)$ $1/$2 permanent; | |
} | |
# --> then redirect request to entry modx index.php | |
location @rewrite { | |
# add trailing slash | |
# rewrite (.*[^/])$ :/// permanent; | |
# remove trailing slash | |
rewrite (.*)/$ $scheme://$host$1 permanent; | |
rewrite ^/(.*)$ /index.php?q=$1 last; | |
} | |
# PHP handler | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass your-backend; | |
} | |
# Hide .htaccess/.htpassword files | |
location ~ /\.ht { | |
# deny all; | |
return 404; | |
} | |
# Custom error page | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
internal; | |
} | |
error_page 404 /404.html; | |
location = /404.html { | |
internal; | |
} | |
error_page 403 /403.html; | |
location = /403.html { | |
internal; | |
} | |
# Include the basic h5bp config set | |
include h5bp/basic.conf; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment