diff --git a/gliders.nginx.conf b/gliders.nginx.conf index 395142312e76e5b3dfdac387cbc872f119349a7c..3212bbb81ee3b2a60cc2bddd92d6da53dfa87bea 100644 --- a/gliders.nginx.conf +++ b/gliders.nginx.conf @@ -1,35 +1,77 @@ -# Configuration for the gliders website -- set it up to use php-fpm etc. +# https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/ +# NOTE: This makes any .php file other than app, app_dev and config.php +# downloadable. If you want one to run, add it to the "pass the PHP scripts to +# upstream FCGI" location section below. Be careful adding PHP files with +# sensitive data like passwords inside them. + +upstream phpfcgi { + server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket +} + server { listen 80; listen 8080; - root /home/gliders/www; - index index.php index.html index.htm; - server_name _; # update with actual hostname when we get it - location / { - try_files $uri $uri/ /index.html; - } + server_name *.gliders.vm; + root /home/gliders/web; - error_page 404 /404.html; - error_page 500 502 503 504 /50x.html; + error_log /var/log/nginx/gliders.error.log; + access_log /var/log/nginx/gliders.access.log; - # Serve static files directly - location ~* \.(png|jpe?g|gif|ico)$ { - expires 1y; - access_log off; - try_files $uri $uri/ @rewrite; - gzip off; + # strip app.php/ prefix if it is present + rewrite ^/app\.php/?(.*)$ /$1 permanent; + + location / { + index app.php; + try_files $uri @rewriteapp; } - location ~* \.(css|js)$ { - expires 1d; - access_log off; + + location @rewriteapp { + rewrite ^(.*)$ /app.php/$1 last; } - location ~ \.php$ { - try_files $uri =404; - fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # pass the PHP scripts to FastCGI server from upstream phpfcgi + location ~ ^/(app|app_dev|config)\.php(/|$) { + fastcgi_pass phpfcgi; + fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS off; } } + +# We don't yet have an SSL cert (not like a VM on my own machine needs one...) +# server { +# listen 443; +# +# server_name *.gliders.vm; +# root /home/gliders/web; +# +# ssl on; +# ssl_certificate /etc/ssl/certs/symfony2.crt; +# ssl_certificate_key /etc/ssl/private/symfony2.key; +# +# error_log /var/log/nginx/symfony2.error.log; +# access_log /var/log/nginx/symfony2.access.log; +# +# # 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(/|$) { +# fastcgi_pass phpfcgi; +# fastcgi_split_path_info ^(.+\.php)(/.*)$; +# include fastcgi_params; +# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +# fastcgi_param HTTPS on; +# } +# } \ No newline at end of file