gliders.nginx.conf 2.22 KB
Newer Older
Owain Jones's avatar
Owain Jones committed
1 2 3 4 5 6 7 8 9 10
# 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
}

root's avatar
root committed
11 12 13 14
server {
    listen 80;
    listen 8080;

Owain Jones's avatar
Owain Jones committed
15 16
    server_name *.gliders.vm;
    root /home/gliders/web;
root's avatar
root committed
17

Owain Jones's avatar
Owain Jones committed
18 19
    error_log /var/log/nginx/gliders.error.log;
    access_log /var/log/nginx/gliders.access.log;
root's avatar
root committed
20

Owain Jones's avatar
Owain Jones committed
21 22 23 24 25 26
    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
root's avatar
root committed
27
    }
Owain Jones's avatar
Owain Jones committed
28 29 30

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
root's avatar
root committed
31 32
    }

Owain Jones's avatar
Owain Jones committed
33 34 35 36
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
root's avatar
root committed
37
        include fastcgi_params;
Owain Jones's avatar
Owain Jones committed
38 39
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
root's avatar
root committed
40 41
    }
}
Owain Jones's avatar
Owain Jones committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

# 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;
#     }
# }