Skip to content

Commit

Permalink
Add custom pages for 502 Bad Gateway pages (#7188)
Browse files Browse the repository at this point in the history
* Add custom pages for 502 Bad Gateway pages

This makes it easier for inexperienced developers to know what they didn't
start when they get an error.

* Fix port number typo
  • Loading branch information
ivarne authored Nov 1, 2021
1 parent f2f4333 commit 005b182
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
17 changes: 17 additions & 0 deletions loadbalancer/502App.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your local Altinn app is not running</title>
</head>
<body>
<h1>502 Bad Gateway</h1>
<h2>Your local APP is not running on port 5005</h2>
<p>Please ensure that your app is running on port 5005</p>
<pre>
> dotnet run --project App/App.csproj
</pre>
</body>
</html>
18 changes: 18 additions & 0 deletions loadbalancer/502LocalTest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Localtest is not running</title>
</head>
<body>
<h1>502 Bad Gateway</h1>
<h2>Localtest is not running</h2>
<p>Please ensure that LocalTest is running on port 5101</p>
<pre>
> cd src/development/LocalTest
> dotnet run
</pre>
</body>
</html>
2 changes: 2 additions & 0 deletions loadbalancer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM nginx:1.21.3-alpine

COPY nginx.conf /etc/nginx/nginx.conf

COPY *.html /www/
12 changes: 10 additions & 2 deletions loadbalancer/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ http {

sendfile on;

upstream localtest {
upstream localtest {
server host.docker.internal:5101;
}

Expand All @@ -25,22 +25,30 @@ http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

error_page 502 /502LocalTest.html;

location = / {
proxy_pass http://localtest/Home/;
}

location / {
proxy_pass http://app/;
error_page 502 /502App.html;
}

location /Home/ {
proxy_pass http://localtest/Home/;
}

location /localtestresources/ {
location /localtestresources/ {
proxy_pass http://localtest/localtestresources/;
}
location /502LocalTest.html {
root /www;
}
location /502App.html {
root /www;
}

}
}

0 comments on commit 005b182

Please sign in to comment.