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

Owain Jones's avatar
Owain Jones committed
7 8 9 10
map $host $symfony_root {
    default /home/gliders/code/gliders-website;
}

Owain Jones's avatar
Owain Jones committed
11 12 13 14
upstream phpfcgi {
    server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}

root's avatar
root committed
15 16 17 18
server {
    listen 80;
    listen 8080;

Owain Jones's avatar
Owain Jones committed
19
    server_name gliders.vm *.gliders.vm;
Owain Jones's avatar
Owain Jones committed
20
    root $symfony_root/web;
root's avatar
root committed
21

Owain Jones's avatar
Owain Jones committed
22 23
    error_log /var/log/nginx/gliders.error.log;
    access_log /var/log/nginx/gliders.access.log;
root's avatar
root committed
24

Owain Jones's avatar
Owain Jones committed
25 26 27 28 29 30
    # 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
31
    }
Owain Jones's avatar
Owain Jones committed
32 33 34

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

Owain Jones's avatar
Owain Jones committed
37 38 39
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
root's avatar
root committed
40
        include fastcgi_params;
Owain Jones's avatar
Owain Jones committed
41 42
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param  SCRIPT_FILENAME $symfony_root/web$fastcgi_script_name;
Owain Jones's avatar
Owain Jones committed
43
        fastcgi_param  HTTPS off;
root's avatar
root committed
44 45
    }
}
Owain Jones's avatar
Owain Jones committed
46 47 48 49 50

# 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
51
#     server_name gliders.vm *.gliders.vm;
Owain Jones's avatar
Owain Jones committed
52
#     root /home/gliders/code/gliders-website/web;
Owain Jones's avatar
Owain Jones committed
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 78 79 80 81
# 
#     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;
#     }
# }