veeRN
veeRN

Reputation: 153

server different 503 pages in apache

i have two apps using the below apache config, app1 listening on 3030 and app2 listening on 3031.

i would like to server different 503 pages for app1 and app2, when i add ErrorDocument 503 /503.html its affecting both app1 and app2, what can be done to server different 503 for app1 and app2

ProxyPass /app1 http://127.0.0.1:3030
ProxyPassReverse /app1 http://127.0.0.1:3030
ProxyPass /app2 http://127.0.0.1:3031
ProxyPassReverse /app2 http://127.0.0.1:3031

Upvotes: 0

Views: 66

Answers (1)

Jota Martos
Jota Martos

Reputation: 4714

Bitnami Engineer here,

If you want different 503 HTMLs for each app, you can use the following code in the /opt/bitnami/apache2/conf/bitnami/bitnami.conf file

  ProxyPass /app1 http://127.0.0.1:3000
  ProxyPassReverse /app1 http://127.0.0.1:3000
  ProxyPass /app2 http://127.0.0.1:3001
  ProxyPassReverse /app2 http://127.0.0.1:3001
  ProxyErrorOverride On
  <Location /app1>
  ErrorDocument 503 /503_custom.html
  </Location>
  <Location /app2>
  ErrorDocument 503 /503.html
  </Location>

I just tried that code with this example express app

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.sendStatus(503);
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

As you can see, it was returning a 503 error code and Apache managed it to send the 503_custom.html site.

Upvotes: 1

Related Questions