Merge pull request #52 from wmurphyrd/webapp-domain
Webapp domain & proxy mode
This commit is contained in:
commit
7cab7937c3
4 changed files with 64 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
* Fix: show correct domain name in guppe instructions on homepage
|
||||||
|
* Add: Support running behind SSL-terminating reverse proxy (PROXY_MODE environment variable)
|
||||||
|
|
||||||
## v1.1.0 (2022-05-1)
|
## v1.1.0 (2022-05-1)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
31
README.md
31
README.md
|
@ -29,6 +29,37 @@ echo DOMAIN=yourdomain.com >> .env
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Updating
|
||||||
|
|
||||||
|
Backup database:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker-compose exec -T mongodb sh -c 'mongodump --archive' > guppe.dump
|
||||||
|
```
|
||||||
|
|
||||||
|
Fetch latest code & restart server:
|
||||||
|
|
||||||
|
```
|
||||||
|
git pull
|
||||||
|
docker-compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Optional configuration
|
||||||
|
|
||||||
|
Additional values can be set in `.env` file
|
||||||
|
|
||||||
|
| Setting | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| PROXY_MODE | Enable use behind an SSL-terminating proxy or load balancer, serves over http instead of https and sets Express `trust proxy` setting to the value of `PROXY_MODE` (e.g. `1`, [other options](https://expressjs.com/en/guide/behind-proxies.html)) See note. |
|
||||||
|
|
||||||
|
**Notes on use with a reverse proxy**: When setting proxyMode, you must ensure your reverse proxy sets the following headers: X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Proto (example for nginx below).
|
||||||
|
|
||||||
|
```
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (c) 2021 William Murphy. Licensed under the AGPL-3
|
Copyright (c) 2021 William Murphy. Licensed under the AGPL-3
|
||||||
|
|
24
index.js
24
index.js
|
@ -4,13 +4,14 @@ const express = require('express')
|
||||||
const MongoClient = require('mongodb').MongoClient
|
const MongoClient = require('mongodb').MongoClient
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const https = require('https')
|
const https = require('https')
|
||||||
|
const http = require('http')
|
||||||
const morgan = require('morgan')
|
const morgan = require('morgan')
|
||||||
const history = require('connect-history-api-fallback')
|
const history = require('connect-history-api-fallback')
|
||||||
const { onShutdown } = require('node-graceful-shutdown')
|
const { onShutdown } = require('node-graceful-shutdown')
|
||||||
const ActivitypubExpress = require('activitypub-express')
|
const ActivitypubExpress = require('activitypub-express')
|
||||||
|
|
||||||
const { version } = require('./package.json')
|
const { version } = require('./package.json')
|
||||||
const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT_HTTPS, DB_URL, DB_NAME } = process.env
|
const { DOMAIN, KEY_PATH, CERT_PATH, CA_PATH, PORT_HTTPS, DB_URL, DB_NAME, PROXY_MODE } = process.env
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const client = new MongoClient(DB_URL)
|
const client = new MongoClient(DB_URL)
|
||||||
|
@ -191,10 +192,23 @@ client.connect()
|
||||||
await apex.store.saveObject(systemUser)
|
await apex.store.saveObject(systemUser)
|
||||||
apex.systemUser = systemUser
|
apex.systemUser = systemUser
|
||||||
}
|
}
|
||||||
|
let server
|
||||||
const server = process.env.NODE_ENV === 'production'
|
if (process.env.NODE_ENV === 'production') {
|
||||||
? AutoEncrypt.https.createServer({ domains: [DOMAIN] }, app)
|
if (PROXY_MODE) {
|
||||||
: https.createServer(sslOptions, app)
|
server = http.createServer(app)
|
||||||
|
try {
|
||||||
|
// boolean or number
|
||||||
|
app.set('trust proxy', JSON.parse(PROXY_MODE))
|
||||||
|
} catch (ignore) {
|
||||||
|
// string
|
||||||
|
app.set('trust proxy', PROXY_MODE)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
server = AutoEncrypt.https.createServer({ domains: [DOMAIN] }, app)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
server = https.createServer(sslOptions, app)
|
||||||
|
}
|
||||||
server.listen(PORT_HTTPS, function () {
|
server.listen(PORT_HTTPS, function () {
|
||||||
console.log('Guppe server listening on port ' + PORT_HTTPS)
|
console.log('Guppe server listening on port ' + PORT_HTTPS)
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
ActivityPub service, but they automatically share anything you send them with all of their followers.
|
ActivityPub service, but they automatically share anything you send them with all of their followers.
|
||||||
</p>
|
</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Follow a group on @a.gup.pe to join that group</li>
|
<li>Follow a group on @{{ domain }} to join that group</li>
|
||||||
<li>Mention a group on @a.gup.pe to share a post with everyone in the group</li>
|
<li>Mention a group on @{{ domain }} to share a post with everyone in the group</li>
|
||||||
<li>New groups are created on demand, just search for or mention @YourGroupNameHere@a.gup.pe and it will show up</li>
|
<li>New groups are created on demand, just search for or mention @YourGroupNameHere@{{ domain }} and it will show up</li>
|
||||||
<li>Visit a @a.gup.pe group profile to see the group history</li>
|
<li>Visit a @{{ domain }} group profile to see the group history</li>
|
||||||
</ol>
|
</ol>
|
||||||
<h2 class="w3-center">Active Groups</h2>
|
<h2 class="w3-center">Active Groups</h2>
|
||||||
<div class="profile-grid w3-margin-bottom w3-mobile">
|
<div class="profile-grid w3-margin-bottom w3-mobile">
|
||||||
|
@ -40,10 +40,11 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
ProfileSummary
|
ProfileSummary
|
||||||
},
|
},
|
||||||
data() {
|
data () {
|
||||||
return {
|
return {
|
||||||
groups: [],
|
groups: [],
|
||||||
error: null
|
error: null,
|
||||||
|
domain: window.location.host
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -56,7 +57,7 @@ export default {
|
||||||
.then(json => {
|
.then(json => {
|
||||||
this.groups = json.orderedItems
|
this.groups = json.orderedItems
|
||||||
})
|
})
|
||||||
.catch(err => this.error = err.message)
|
.catch(err => (this.error = err.message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -77,4 +78,4 @@ export default {
|
||||||
.profile-image {
|
.profile-image {
|
||||||
width: 75px;
|
width: 75px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue