Created
October 24, 2013 12:23
-
-
Save cedricziel/7136243 to your computer and use it in GitHub Desktop.
Wildcard vhosts with nginx on a dev machine 1. Place wildcard.conf in /etc/nginx/sites-enabled or symlink it here
2. Place typo3 in /etc/nginx
3. Adjust the paths. I prefer to hold anything inside ~/public_html (needs adjustments. wire up www-data [or your systems flavor of that) and your current user group. Also let your php-fpm pool use your u…
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
address=/t3cmsdev/127.0.0.1 | |
address=/l/127.0.0.1 | |
address=/silex/127.0.0.1 | |
address=/symfony2/127.0.0.1 | |
address=/dev/127.0.0.1 |
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
index index.php index.html; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
expires max; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
# location ~ /. { | |
# deny all; | |
# access_log off; | |
# log_not_found off; | |
# } | |
location ~* .(jpg|jpeg|png|gif|css|js|ico)$ { | |
expires max; | |
log_not_found off; | |
} | |
location ~* .(cur|ico|gif|png|jpe?g|css|js|swf|woff)$ { | |
expires max; | |
log_not_found off; | |
} | |
location ~* ^(/typo3/sysext|/typo3conf/ext).*.(cur|ico|gif|png|jpe?g|css|js|swf|woff) { | |
expires max; | |
log_not_found off; | |
} | |
location ~* "\.js\.gzip$" { | |
add_header Content-Encoding gzip; | |
gzip off; | |
default_type application/javascript; | |
} | |
location ~* "\.css\.gzip$" { | |
add_header Content-Encoding gzip; | |
gzip off; | |
types { text/css gzip; } | |
} | |
location = /clear.gif { | |
empty_gif; | |
expires max; | |
} | |
location ^~ /typo3/gfx { | |
expires max; | |
} | |
location ^~ /typo3temp/compressor { | |
expires max; | |
} | |
location ~* .(sql|htaccess|htpasswd|tpl|html5|xhtml) { | |
deny all; | |
} | |
location / { | |
if ($query_string ~ ".+") { | |
return 405; | |
} | |
# pass requests from logged-in users to PHP | |
if ($http_cookie = 'nc_staticfilecache|be_typo_user' ) { | |
return 405; | |
} # pass POST requests to PHP | |
if ($request_method !~ ^(GET|HEAD)$ ) { | |
return 405; | |
} | |
if ($http_pragma = 'no-cache') { | |
return 405; | |
} | |
if ($http_cache_control = 'no-cache') { | |
return 405; | |
} | |
error_page 405 = @nocache; | |
# serve requested content from the cache if available, otherwise pass the request to PHP | |
try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache; | |
} | |
location @nocache { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ^~ /typo3temp/tx_ncstaticfilecache { | |
expires 43200; | |
charset utf-8; | |
} | |
location ~ .php$ { | |
try_files $uri =404; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_index index.php; | |
} |
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
# TYPO3 Flow/Neos | |
server { | |
listen 80; | |
server_name ~^(?<project>.*)\.dev$; | |
root /home/cziel/public_html/$project/Web; | |
client_max_body_size 50M; | |
index index.php; | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
try_files $uri $uri/ /index.php?$args; | |
location ~ \.php$ { | |
include fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param FLOW_CONTEXT Development; | |
fastcgi_param FLOW_REWRITEURLS 1; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
location ~ "^/_Resources/Persistent/" { | |
rewrite "(.{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break; | |
rewrite "([a-z0-9]+/(.+/)?[a-f0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ { | |
access_log off; | |
expires max; | |
} | |
} | |
# TYPO3 CMS | |
server { | |
server_name ~^(?<project>.*)\.t3cmsdev$; | |
root /home/cziel/public_html/$project; | |
index index.html index.htm; | |
# Make site accessible from http://localhost/ | |
include /etc/nginx/typo3; | |
} | |
# plain jane PHP projects with index.php on project root | |
server { | |
listen 80; | |
server_name ~^(?<project>.*)\.l$; | |
root /home/cziel/public_html/$project; | |
client_max_body_size 50M; | |
index index.php; | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
try_files $uri $uri/ /index.php?$args; | |
location ~ \.php$ { | |
include fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ { | |
access_log off; | |
expires max; | |
} | |
} | |
# Silex projects | |
server { | |
listen 80; | |
server_name ~^(?<project>.*)\.silex$; | |
root /home/cziel/public_html/$project/web; | |
client_max_body_size 50M; | |
index index.php; | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
try_files $uri $uri/ /index.php?$args; | |
location ~ \.php$ { | |
include fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ { | |
access_log off; | |
expires max; | |
} | |
} | |
# SF2 Projects | |
server { | |
listen 80; | |
server_name ~^(?<project>.*)\.symfony2$; | |
root /home/cziel/public_html/$project/web; | |
# strip app.php/ prefix if it is present | |
rewrite ^/app\.php/?(.*)$ /$1 permanent; | |
location / { | |
index app.php; | |
try_files $uri @rewriteapp; | |
} | |
location @rewriteapp { | |
rewrite ^(.*)$ /app.php/$1 last; | |
} | |
# pass the PHP scripts to FastCGI server from upstream phpfcgi | |
location ~ ^/(app|app_dev|config)\.php(/|$) { | |
include fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param HTTPS off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment