gliders.nginx.conf 2.32 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;
}

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

15
    server_name gliders.vm dev.gliders.vm;
Owain Jones's avatar
Owain Jones committed
16
    root $symfony_root/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
    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
25
        index app_dev.php;
Owain Jones's avatar
Owain Jones committed
26
        try_files $uri @rewriteapp;
root's avatar
root committed
27
    }
Owain Jones's avatar
Owain Jones committed
28

root's avatar
root committed
29 30 31 32
    location /static/logs {
        alias /var/gliders/logs;
    }

Owain Jones's avatar
Owain Jones committed
33
    location @rewriteapp {
34
        rewrite ^(.*)$ /app_dev.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
# 
#     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;
#     }
81
# }