server {
        listen 80 default_server;
        listen [::]:80 default_server;

	server_name fic.srs.epita.fr;

        access_log /var/log/nginx/fic2016.access_log main;
        error_log /var/log/nginx/fic2016.error_log info;

        root /srv/www/fic2016-static/;

        error_page 403 404 /e404.html;
        error_page 413 404 /e413.html;
        error_page 500 502 504 /e500.html;

        location /.htaccess {
            return 404;
        }
        location /chbase.sh {
            return 404;
        }

        location ~ ^/[0-9] {
            rewrite ^/.*$ /index.html;
        }

        location /edit {
            rewrite ^/.*$ /index.html;
        }

        location /rank {
            rewrite ^/.*$ /index.html;
        }

        location /tags/ {
            rewrite ^/.*$ /index.html;
        }

        location /files/ {
	    sendfile    on;
            tcp_nodelay on;
            gzip_static  always;
        }

	location = /welcome.html {
	    internal;
	    if ($http_accept ~ "^application/json") {
	        rewrite ^/(.*).html$ /$1.json;
	    }
	}
	location = /e404.html {
	    internal;
	    if ($http_accept ~ "^application/json") {
	        rewrite ^/(.*).html$ /$1.json;
	    }
        }
	location = /e413.html {
	    internal;
	    if ($http_accept ~ "^application/json") {
	        rewrite ^/(.*).html$ /$1.json;
	    }
        }
	location = /e500.html {
	    internal;
	    if ($http_accept ~ "^application/json") {
	        rewrite ^/(.*).html$ /$1.json;
	    }
        }
}
