server { listen 443 ssl; server_name api.urbancanopee.com; # managed by Certbot ssl_certificate /etc/letsencrypt/live/api.urbancanopee.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/api.urbancanopee.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # SEO trailing slash problem fix rewrite ^/(.*)/$ /$1 permanent; # remove trailing slash #rewrite ^(.*[^/])$ $1/ permanent; # add a trailing slash root /opt/services/urban-canopee-api/public; # Laravels public folder access_log /opt/services/urban-canopee-api/storage/logs/nginx.access.log; error_log /opt/services/urban-canopee-api/storage/logs/nginx.error.log; autoindex on; index index.php; # set max upload size to 2M client_max_body_size 10m; # Cache static files for a long time include global/static-asset-caching.conf; # Pull in some good PHP defaults include global/php-restrictions.conf; location / { # First try and load files from the public folder, if they don't exist # then send the request through to laravel try_files $uri $uri/ /index.php?$query_string; } error_page 404 /index.php; # Forward requests on to PHP-FPM location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } } # Force HTTPS server { listen 80; server_name api.urbancanopee.com; return 301 https://$host$request_uri; }