gliders.nginx.conf 3.07 KB
Newer Older
Owain Jones's avatar
Owain Jones committed
1 2 3
# 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
root's avatar
root committed
4
# upstream FCGI" location section below. Be careful adding files with
Owain Jones's avatar
Owain Jones committed
5 6
# sensitive data like passwords inside them.

Owain Jones's avatar
Owain Jones committed
7
map $host $symfony_root {
root's avatar
root committed
8 9 10 11 12 13
    # default /home/gliders/code/gliders-website;
    default /var/gliders/www;
}

map $host $symfony_root_dev {
   default /var/gliders/www_dev;
Owain Jones's avatar
Owain Jones committed
14 15
}

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

root's avatar
root committed
19
    server_name 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

root's avatar
root committed
25 26 27 28 29
    # Enable compression. Very helpful when we're getting stuff like
    # large amounts of vehicle tracks in JSON form!
    gzip on;
    gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript;

Owain Jones's avatar
Owain Jones committed
30 31 32
    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

root's avatar
root committed
33 34 35 36 37 38 39 40 41 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 78 79 80
    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location ~ ^/(images|fonts|css|js) {
        access_log off;
        error_log off;
        try_files $uri =404;
        expires 1y;
        add_header Cache-Control "public";
    }

    location /static/logs {
        alias /var/gliders/logs;
    }

    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;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param  SCRIPT_FILENAME $symfony_root/web$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}

server {
    listen 80;

    server_name dev.gliders.vm;
    root $symfony_root_dev/web;

    error_log /var/log/nginx/dev.gliders.error.log;
    access_log /var/log/nginx/dev.gliders.access.log;

    # Enable compression. Very helpful when we're getting stuff like
    # large amounts of vehicle tracks in JSON form!
    gzip on;
    gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript;

    # strip app.php/ prefix if it is present
    rewrite ^/app_dev\.php/?(.*)$ /$1 permanent;

Owain Jones's avatar
Owain Jones committed
81
    location / {
82
        index app_dev.php;
Owain Jones's avatar
Owain Jones committed
83
        try_files $uri @rewriteapp;
root's avatar
root committed
84
    }
Owain Jones's avatar
Owain Jones committed
85

root's avatar
root committed
86 87 88 89 90 91 92 93
    location ~ ^/(images|fonts|css|js) {
        access_log off;
        error_log off;
        try_files $uri =404;
        expires 1y;
        add_header Cache-Control "public";
    }

root's avatar
root committed
94 95 96 97
    location /static/logs {
        alias /var/gliders/logs;
    }

Owain Jones's avatar
Owain Jones committed
98
    location @rewriteapp {
99
        rewrite ^(.*)$ /app_dev.php/$1 last;
root's avatar
root committed
100 101
    }

Owain Jones's avatar
Owain Jones committed
102 103 104
    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfcgi;
root's avatar
root committed
105
        include fastcgi_params;
Owain Jones's avatar
Owain Jones committed
106
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
root's avatar
root committed
107
        fastcgi_param  SCRIPT_FILENAME $symfony_root_dev/web$fastcgi_script_name;
Owain Jones's avatar
Owain Jones committed
108
        fastcgi_param  HTTPS off;
root's avatar
root committed
109 110
    }
}
Owain Jones's avatar
Owain Jones committed
111