Last active
May 5, 2016 15:54
-
-
Save Mikulas/061596868cd7b7dbcaa9bd85612a5e58 to your computer and use it in GitHub Desktop.
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 { | |
listen *:80; | |
listen [::]:80; | |
server_name test.dev; | |
return 301 https://$http_host$request_uri; | |
} | |
server { | |
listen *:443 ssl; | |
listen [::]:443 ssl; | |
server_name test.dev; | |
root /Users/mikulas/Projects/test/www; | |
disable_symlinks off; | |
index index.php; | |
include tls.conf; | |
ssl_certificate /Users/mikulas/Forks/certs/test.dev.fullchain; | |
ssl_certificate_key /Users/mikulas/Forks/certs/test.dev.key; | |
include static.conf; | |
location / { | |
rewrite [^/]$ $uri/; | |
try_files $uri $uri/ @php-catchall; | |
fastcgi_pass unix:/usr/local/var/run/php70-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ \.php$ { | |
try_files $uri $uri/ @php-catchall; | |
fastcgi_pass unix:/usr/local/var/run/php70-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# used for missing static files | |
location @php-catchall { | |
fastcgi_pass unix:/usr/local/var/run/php70-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | |
fastcgi_param SCRIPT_NAME index.php; | |
fastcgi_param DOCUMENT_URI $request_uri; | |
} | |
} |
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
location ~ \.(?!php)[^.]+$ { | |
try_files $uri @php-catchall; | |
access_log off; | |
log_not_found off; | |
expires max; | |
add_header Cache-Control "public"; | |
gzip on; | |
gzip_comp_level 5; | |
gzip_min_length 256; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_vary on; | |
gzip_types *; # process all | |
} |
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
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
export DOMAIN="test.dev" | |
function request { | |
URL="$1" | |
curl -sS -v -L "$DOMAIN/$URL" | |
} | |
function serves { | |
URL="$1" | |
EXPECTED="$2" | |
REAL="$(request "$URL" 2> /dev/null)" | |
if [ "$EXPECTED" = "$REAL" ]; then | |
return 0 | |
else | |
>&2 echo "... exp: $EXPECTED <> real: $REAL" | |
return 1 | |
fi | |
} | |
CODE=0 | |
function assert { | |
GREEN="\033[32m" | |
RED="\033[31m" | |
RESET="\033[0m" | |
if $("$@"); then | |
echo -e "$2\t ${GREEN}ok${RESET}" | |
else | |
echo -e "$2\t ${RED}failed${RESET}" | |
CODE=1 | |
fi | |
} | |
assert serves "/" "/index.php" | |
assert serves "/index.php" "/index.php" | |
assert serves "/index.php?q=f" "/index.php" | |
assert serves "/secondary.php" "/secondary.php" | |
assert serves "/any" "/index.php" | |
assert serves "/any/" "/index.php" | |
assert serves "/any.xml" "/index.php" | |
assert serves "/any.php" "/index.php" | |
assert serves "/static.xml" "/static.xml" | |
assert serves "/admin" "/admin/index.php" | |
assert serves "/admin/" "/admin/index.php" | |
assert serves "/admin/index.php" "/admin/index.php" | |
assert serves "/admin/static.xml" "/admin/static.xml" | |
assert serves "/admin/any" "/index.php" | |
exit "$CODE" |
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
. | |
└── www | |
├── admin | |
│ ├── index.php | |
│ └── static.xml | |
├── index.php | |
├── secondary.php | |
└── static.xml | |
2 directories, 5 files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment