Skip to content

Commit

Permalink
HAWNG-6: Adds custom 404 and 50x error pages
Browse files Browse the repository at this point in the history
* Avoids revealing type or version of web server used by displaying
  custom error pages
  • Loading branch information
phantomjinx authored and tadayosi committed Nov 15, 2023
1 parent f6aa0b3 commit ebb28a9
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ RUN mkdir -p /usr/share/nginx/html/online/osconsole && \
COPY docker/nginx.js docker/rbac.js docker/js-yaml.js docker/jwt-decode.js /etc/nginx/conf.d/
COPY docker/nginx.conf docker/nginx-gateway.conf.template docker/nginx-gateway-k8s.conf.template docker/osconsole/config.sh docker/nginx.sh docker/ACL.yaml /

COPY docker/hawtio-50x.html /usr/share/nginx/html
COPY docker/hawtio-404.html /usr/share/nginx/html

# Copy licenses
RUN mkdir -p /opt/hawtio/licenses
COPY docker/licenses /opt/hawtio/licenses
Expand Down
13 changes: 13 additions & 0 deletions docker/hawtio-404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div style="text-align: center">
<h1>Whoops!</h1>
<p style="color: red; font-weight: bold;">
404 Page Not Found
</p>
<div>
<span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%">
<img alt="Hawtio Logo" src="/online/hawtio-logo.svg">
</span>
</div>
<p class=>Try <a title="Go to Hawtio Online" href="/online">Hawtio</a>.
</p>
</div>
13 changes: 13 additions & 0 deletions docker/hawtio-50x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div style="text-align: center">
<h1>Whoops!</h1>
<p style="color: red; font-weight: bold;">
A connection error occurred.
</p>
<div>
<span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%">
<img alt="Hawtio Logo" src="/online/hawtio-logo.svg">
</span>
</div>
<p class=>Try <a title="Go to Hawtio Online" href="/online">Hawtio</a>.
</p>
</div>
10 changes: 10 additions & 0 deletions docker/nginx-gateway-k8s.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ server {
rewrite ^ $new redirect;
}

error_page 404 /hawtio-404.html;
location = /hawtio-404.html {
internal;
}

error_page 500 502 503 504 /hawtio-50x.html;
location = /hawtio-50x.html {
internal;
}

# Static content serving
location /online {
add_header location-rule ONLINE always;
Expand Down
10 changes: 10 additions & 0 deletions docker/nginx-gateway.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ server {
rewrite ^ $new redirect;
}

error_page 404 /hawtio-404.html;
location = /hawtio-404.html {
internal;
}

error_page 500 502 503 504 /hawtio-50x.html;
location = /hawtio-50x.html {
internal;
}

# Static content serving
location /online {
add_header location-rule ONLINE always;
Expand Down
10 changes: 10 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ server {
rewrite ^ $new redirect;
}

error_page 404 /hawtio-404.html;
location = /hawtio-404.html {
internal;
}

error_page 500 502 503 504 /hawtio-50x.html;
location = /hawtio-50x.html {
internal;
}

# Static content serving
location /online {
alias /usr/share/nginx/html/online;
Expand Down

0 comments on commit ebb28a9

Please sign in to comment.