aboutsummaryrefslogtreecommitdiffstats
path: root/conf/nginx.conf.example
blob: 7b26afdbfcdd159a93bdc1ea20c2dbc66a6c2868 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
# An example configuration for running FixMyStreet under nginx.  You
# will also need to set up the FixMyStreet Catalyst FastCGI backend.
# An example sysvinit script to help with this is shown given in the file
# sysvinit-catalyst-fastcgi.example in this directory.
#
# See our installation help at http://code.fixmystreet.com/

server {

    access_log /var/www/fixmystreet/logs/access.log;
    error_log /var/www/fixmystreet/logs/error.log;

    listen 80;
    root /var/www/fixmystreet/fixmystreet/web;
    error_page 503 /down.html;

    # Make sure that Javascript and CSS are compressed.  (HTML is
    # already compressed under the default configuration of the nginx
    # package.)

    gzip on;
    gzip_disable "msie6";
    gzip_types application/javascript application/x-javascript text/css;

    # Set a long expiry time for CSS and Javascript, and prevent
    # the mangling of Javascript by proxies:

    location ~ \.css$ {
        expires 10y;
    }

    location ~ \.js$ {
        add_header Cache-Control no-transform;
        expires 10y;
        try_files $uri @catalyst;
    }

    # These rewrite rules are ported from the Apache configuration in
    # conf/httpd.conf

    rewrite ^/rss/council/([0-9]+)$  /rss/reports/$1 permanent;
    rewrite ^/report$                /reports        permanent;
    rewrite '^/{/rss/(.*)}$'         /rss/$1         permanent;
    rewrite '^/reports/{/rss/(.*)}$' /rss/$1         permanent;
    rewrite ^/alerts/?$              /alert          permanent;

    location /mapit {
        proxy_pass http://mapit.mysociety.org/;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /admin {
        auth_basic "FixMyStreet admin interface";
        auth_basic_user_file /var/www/fixmystreet/admin-htpasswd;
        try_files $uri @catalyst;
    }

    location / {
        if (-f $document_root/down.html) {
            return 503;
        }
        try_files $uri @catalyst;
    }

    location /down.html {
        internal;
    }

    location @catalyst {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param SCRIPT_NAME '';
        fastcgi_pass 127.0.0.1:9000;
    }
}