# == victorwesterlund.com ==

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

        server_name www.victorwesterlund.com victorwesterlund.com;

        return 301 https://victorwesterlund.com$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        server_name victorwesterlund.com;

        ssl on;
        include snippets/ssl.conf;

        root /var/www/github_victorwesterlund_victorwesterlund.com/public;
        error_page 404 403 /not_found.html;

        location \ {
                try_files $uri $uri.html $uri/ =404;
        }

        location ~ \.php$ {
                add_header Access-Control-Allow-Origin *;
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }

        location ~ /\.git {
                deny all;
                return 404;
        }
}

# == api.victorwesterlund.com ==

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

        server_name api.victorwesterlund.com;

        return 301 https://api.victorwesterlund.com$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        server_name api.victorwesterlund.com;

        ssl on;
        include snippets/ssl.conf;

        root /var/www/github_victorwesterlund_victorwesterlund.com/api;

        location \* {
                try_files /router.php$request_uri =404;
                add_header Access-Control-Allow-Origin *;
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }

        location ~ /\.git {
                deny all;
                return 404;
        }
}