Created
October 27, 2014 12:08
-
-
Save ameliaikeda/29b72706de995b53aaa0 to your computer and use it in GitHub Desktop.
nginx config for dynamic subdomain:subdirectory mapping
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
user ameliaikeda staff; | |
worker_processes 2; | |
error_log /Users/ameliaikeda/dev/error.log info; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 256; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
# '$status $body_bytes_sent "$http_referer" ' | |
# '"$http_user_agent" "$http_x_forwarded_for"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
client_max_body_size 128m; | |
#gzip on; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
server { | |
listen 80; | |
listen 443 ssl; | |
ssl_certificate /Users/ameliaikeda/dev/keys/amelia.pw.pem; | |
ssl_certificate_key /Users/ameliaikeda/dev/keys/amelia.pw.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
# prefer our ciphers, clients requesting something else will | |
# be told to sod off and pick something from our list | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers EECDH+HIGH+AES:EDH+HIGH+AES:!PSK:!SRP:!aNULL; | |
# session cache for requests that is shared between | |
# workers so they dont need to STARTLS | |
ssl_session_cache shared:SSL:10m; | |
# Strict Transport Security for browsers | |
add_header Strict-Transport-Security max-age=15555000; | |
index index.html index.php; | |
server_name ~^(?<subdomain>.+)\.(amelia\.pw|local\.dev|dev|local)$; | |
root /Users/ameliaikeda/dev/$subdomain/public; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include fastcgi.conf; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can expand this to whole domains in fact (if you wanted to let users pick their own custom domains).