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

        server_name emacsconf.org www.emacsconf.org;
        return 302 https://$server_name$request_uri;
}

server {
        listen 443 ssl http2;
        #listen [::]:443 ssl;
        server_name www.emacsconf.org;
        include /etc/nginx/tls/emacsconf.org.conf;
        return 302 https://emacsconf.org$request_uri;
}

upstream omec {
        server 127.0.0.1:11937;
}

server {
        listen 443 ssl http2;
        #listen [::]:443 ssl;
        server_name emacsconf.org;

        include /etc/nginx/tls/emacsconf.org.conf;

        location / {
                if ($is_args = "") { rewrite ^(.*)/main$ /$1 redirect; }
                # if ($request_uri ~ "^/([\d]{4})/$") { return 302 /$1; }

                proxy_pass http://omec;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;

                location /config   { alias /opt/oddmuse-emacsconf/data/config; default_type text/plain; }
                location /s/ { root /opt/oddmuse-emacsconf/data; }
                location /videos {
                        alias /var/www/video.emacsconf.org;
                        autoindex on;
                        autoindex_exact_size off;
                }
        }
}