Skip to content

Commit

Permalink
Changes to nginx @maintenance handler
Browse files Browse the repository at this point in the history
previous configuration would not display maintenance page if omero.web
wasn't running.  This was likely due to the request being passed to the
@proxy_to_app named location and the configuration not being inherited
into that stanza.

This commit moves the error_page directive up to the server container
where possible or duplicates the directive into the named location
directive otherwise.

Additionally the return code is set to 502 to avoid situations where
returning the maintenance page causes a 200 return code and confusing
monitoring systems.  (502 is always 502 with the current configuration.
  • Loading branch information
stick authored and knabar committed May 7, 2024
1 parent 02bd670 commit 76fc6ec
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion omeroweb/templates/nginx-development.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ http {

sendfile on;
client_max_body_size %(MAX_BODY_SIZE)s;
error_page 502 =502 @maintenance%(PREFIX_NAME)s;

%(NGINX_SERVER_EXTRA_CONFIG)s

Expand All @@ -59,7 +60,6 @@ http {

location %(FORCE_SCRIPT_NAME)s {

error_page 502 @maintenance%(PREFIX_NAME)s;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app%(PREFIX_NAME)s;
}
Expand Down
3 changes: 2 additions & 1 deletion omeroweb/templates/nginx-location.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ location %(STATIC_URL)s {
}

location @proxy_to_app%(PREFIX_NAME)s {
error_page 502 =502 @maintenance%(PREFIX_NAME)s;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
Expand All @@ -37,7 +38,7 @@ location @proxy_to_app%(PREFIX_NAME)s {

location %(FORCE_SCRIPT_NAME)s {

error_page 502 @maintenance%(PREFIX_NAME)s;
error_page 502 =502 @maintenance%(PREFIX_NAME)s;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app%(PREFIX_NAME)s;
}
2 changes: 1 addition & 1 deletion omeroweb/templates/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ server {

sendfile on;
client_max_body_size %(MAX_BODY_SIZE)s;
error_page 502 =502 @maintenance%(PREFIX_NAME)s;

%(NGINX_SERVER_EXTRA_CONFIG)s

Expand All @@ -34,7 +35,6 @@ server {

location %(FORCE_SCRIPT_NAME)s {

error_page 502 @maintenance%(PREFIX_NAME)s;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app%(PREFIX_NAME)s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ http {

sendfile on;
client_max_body_size 2m;
error_page 502 =502 @maintenance_test;

# <<<<< omero.web.nginx_server_extra_config
listen 443 ssl;
Expand Down Expand Up @@ -63,7 +64,6 @@ ssl_certificate_key /dummy/private.key;

location /test {

error_page 502 @maintenance_test;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app_test;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reference_templates/nginx-development.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ http {

sendfile on;
client_max_body_size 0;
error_page 502 =502 @maintenance;



Expand All @@ -59,7 +60,6 @@ http {

location / {

error_page 502 @maintenance;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ location /test-static {
}

location @proxy_to_app_test {
error_page 502 =502 @maintenance_test;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
Expand All @@ -37,7 +38,7 @@ location @proxy_to_app_test {

location /test {

error_page 502 @maintenance_test;
error_page 502 =502 @maintenance_test;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app_test;
}
Expand Down
3 changes: 2 additions & 1 deletion test/unit/reference_templates/nginx-location.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ location /static {
}

location @proxy_to_app {
error_page 502 =502 @maintenance;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
Expand All @@ -37,7 +38,7 @@ location @proxy_to_app {

location / {

error_page 502 @maintenance;
error_page 502 =502 @maintenance;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reference_templates/nginx-withoptions.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ server {

sendfile on;
client_max_body_size 2m;
error_page 502 =502 @maintenance_test;

# <<<<< omero.web.nginx_server_extra_config
listen 443 ssl;
Expand Down Expand Up @@ -38,7 +39,6 @@ ssl_certificate_key /dummy/private.key;

location /test {

error_page 502 @maintenance_test;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app_test;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reference_templates/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ server {

sendfile on;
client_max_body_size 0;
error_page 502 =502 @maintenance;



Expand All @@ -34,7 +35,6 @@ server {

location / {

error_page 502 @maintenance;
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
Expand Down

0 comments on commit 76fc6ec

Please sign in to comment.