Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor(nginx): streamline default Nginx configuration and improve error handling

Andras Bacsai2c845461c957
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 17ddcbda00..db3085649a 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -4054,29 +4054,24 @@ function defaultNginxConfiguration(): string
{
return 'server {
location / {
- root /usr/share/nginx/html;
- index index.html index.htm;
- try_files $uri $uri.html $uri/index.html $uri/index.htm $uri/ /index.html /index.htm =404;
+ root /usr/share/nginx/html;
+ index index.html index.htm;
+ try_files $uri $uri.html $uri/index.html $uri/index.htm $uri/ =404;
}
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
+ # Handle 404 errors
+ error_page 404 /404.html;
+ location = /404.html {
root /usr/share/nginx/html;
- try_files $uri @redirect_to_index;
internal;
}
- error_page 404 = @handle_404;
-
- location @handle_404 {
+ # Handle server errors (50x)
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
root /usr/share/nginx/html;
- try_files /404.html @redirect_to_index;
internal;
}
-
- location @redirect_to_index {
- return 302 /;
- }
}';
}