gliders.nginx.conf 2.19 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
    server_name gliders.vm *.gliders.vm;
Owain Jones's avatar
Owain Jones committed
16
    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
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
root's avatar
root committed
36
        include fastcgi_params;
Owain Jones's avatar
Owain Jones committed
37 38
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
root's avatar
root committed
39 40
    }
}
Owain Jones's avatar
Owain Jones committed
41 42 43 44 45

# We don't yet have an SSL cert (not like a VM on my own machine needs one...)
# server {
#     listen 443;
# 
Owain Jones's avatar
Owain Jones committed
46
#     server_name gliders.vm *.gliders.vm;
Owain Jones's avatar
Owain Jones committed
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
#     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;
#     }
# }