Created
May 19, 2014 07:54
-
-
Save jakubriedl/352d98f60d89308c701b to your computer and use it in GitHub Desktop.
nginx + laravel API vhost
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 443 ssl; | |
server_name api.example.com; | |
root /var/www/api/public/; | |
index index.php index.html index.htm; | |
### Begin SSL | |
ssl_certificate /etc/ssl/custom/api.example.com.crt; | |
ssl_certificate_key /etc/ssl/custom/api.example.com.key; | |
ssl_session_cache shared:SSL:1m; | |
ssl_session_timeout 5m; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
ssl_prefer_server_ciphers on; | |
### END SSL | |
gzip on; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
client_max_body_size 10M; | |
location / | |
{ | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# catch all | |
error_page 404 /index.php; | |
# The PHP Inclusion Block | |
# include /etc/nginx/includes/php; | |
location ~ \..*/.*\.php$ | |
{ | |
# I'm pretty sure this stops people trying to traverse your site to get to other PHP files | |
return 403; | |
} | |
location ~ \.php(.*)$ | |
{ | |
# Pass the PHP files to PHP FastCGI for processing | |
try_files $uri = 404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; # 127.0.0.1:9000; | |
fastcgi_index index.php; | |
} | |
# Deny Any Access to .htaccess Files That May Be Present (not usually in issue in Laravel) | |
# include /etc/nginx/includes/deny_htaccess; | |
location ~ /\.ht | |
{ | |
deny all; | |
} | |
} | |
server { | |
listen 80; | |
server_name api.le.cz; | |
root /var/www/api/public/; | |
index index.php index.html index.htm; | |
gzip on; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
client_max_body_size 10M; | |
location / | |
{ | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# catch all | |
error_page 404 /index.php; | |
# The PHP Inclusion Block | |
# include /etc/nginx/includes/php; | |
location ~ \..*/.*\.php$ | |
{ | |
# I'm pretty sure this stops people trying to traverse your site to get to other PHP files | |
return 403; | |
} | |
location ~ \.php(.*)$ | |
{ | |
# Pass the PHP files to PHP FastCGI for processing | |
try_files $uri = 404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; # 127.0.0.1:9000; | |
fastcgi_index index.php; | |
} | |
# Deny Any Access to .htaccess Files That May Be Present (not usually in issue in Laravel) | |
# include /etc/nginx/includes/deny_htaccess; | |
location ~ /\.ht | |
{ | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment