<% if @nginx_http_only != '' -%>
<% else -%>
server {
    listen 80;
    listen [::]:80;

    location / {
        return 301 https://$host$request_uri;
    }

    include /etc/nginx/zulip-include/certbot;
}
<% end -%>

include /etc/nginx/zulip-include/upstreams;

server {
<% if @nginx_http_only != '' -%>
    listen 80;
    listen [::]:80;
<% else -%>
    listen <%= @nginx_listen_port %> http2;
    listen [::]:<%= @nginx_listen_port %> http2;

    ssl on;
    ssl_certificate <%= @ssl_dir %>/certs/zulip.combined-chain.crt;
    ssl_certificate_key <%= @ssl_dir %>/private/zulip.key;
<% end -%>

<% if @no_serve_uploads == '' -%>
    location /user_avatars {
        include /etc/nginx/zulip-include/headers;
        add_header Content-Security-Policy "default-src 'none' img-src 'self'";
        include /etc/nginx/zulip-include/uploads.types;
        alias /home/zulip/uploads/avatars;
    }
<% end -%>

    location /local-static {
        alias /home/zulip/local-static;
    }

    include /etc/nginx/zulip-include/certbot;
    include /etc/nginx/zulip-include/app;
}
