mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Split out docs, better error handling when database config doesn't exist
This commit is contained in:
parent
e1c38484ed
commit
8a2996f651
10
Dockerfile
10
Dockerfile
@ -19,11 +19,11 @@ RUN curl -L -o /tmp/s6-overlay-amd64.tar.gz "https://github.com/just-containers/
|
|||||||
# App
|
# App
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
ADD dist /srv/app/dist
|
ADD dist /app/dist
|
||||||
ADD node_modules /srv/app/node_modules
|
ADD node_modules /app/node_modules
|
||||||
ADD src/backend /srv/app/src/backend
|
ADD src/backend /app/src/backend
|
||||||
ADD package.json /srv/app/package.json
|
ADD package.json /app/package.json
|
||||||
ADD knexfile.js /srv/app/knexfile.js
|
ADD knexfile.js /app/knexfile.js
|
||||||
|
|
||||||
# Volumes
|
# Volumes
|
||||||
VOLUME [ "/data", "/etc/letsencrypt" ]
|
VOLUME [ "/data", "/etc/letsencrypt" ]
|
||||||
|
@ -19,11 +19,11 @@ RUN curl -L -o /tmp/s6-overlay-armhf.tar.gz "https://github.com/just-containers/
|
|||||||
# App
|
# App
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
ADD dist /srv/app/dist
|
ADD dist /app/dist
|
||||||
ADD node_modules /srv/app/node_modules
|
ADD node_modules /app/node_modules
|
||||||
ADD src/backend /srv/app/src/backend
|
ADD src/backend /app/src/backend
|
||||||
ADD package.json /srv/app/package.json
|
ADD package.json /app/package.json
|
||||||
ADD knexfile.js /srv/app/knexfile.js
|
ADD knexfile.js /app/knexfile.js
|
||||||
|
|
||||||
# Volumes
|
# Volumes
|
||||||
VOLUME [ "/data", "/etc/letsencrypt" ]
|
VOLUME [ "/data", "/etc/letsencrypt" ]
|
||||||
|
43
README.md
43
README.md
@ -19,52 +19,17 @@ running at home or otherwise, including free SSL, without having to know too muc
|
|||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
### Method 1: Using docker-compose
|
Please consult the [installation instructions](doc/INSTALL.md) for a complete guide or
|
||||||
|
if you just want to get up and running in the quickest time possible, grab all the files in the `doc/example/` folder and run `docker-compose up -d`
|
||||||
|
|
||||||
By far the easiest way to get up and running. Create this `docker-compose.yml`
|
|
||||||
|
|
||||||
```yml
|
|
||||||
version: "2"
|
|
||||||
services:
|
|
||||||
app:
|
|
||||||
image: jc21/nginx-proxy-manager:preview
|
|
||||||
ports:
|
|
||||||
- 80:80
|
|
||||||
- 81:81
|
|
||||||
- 443:443
|
|
||||||
volumes:
|
|
||||||
- ./data:/data
|
|
||||||
- ./letsencrypt:/etc/letsencrypt
|
|
||||||
```
|
|
||||||
|
|
||||||
Then:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Method 2: Using vanilla docker
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d \
|
|
||||||
-p 80:80 \
|
|
||||||
-p 81:81 \
|
|
||||||
-p 443:443 \
|
|
||||||
-v /path/to/data:/data \
|
|
||||||
-v /path/to/letsencrypt:/etc/letsencrypt \
|
|
||||||
jc21/nginx-proxy-manager
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Administration
|
## Administration
|
||||||
|
|
||||||
Now that your docker container is running, connect to it on port `81` for the admin interface.
|
When your docker container is running, connect to it on port `81` for the admin interface.
|
||||||
|
|
||||||
[http://localhost:81](http://localhost:81)
|
[http://localhost:81](http://localhost:81)
|
||||||
|
|
||||||
From here, the rest should be self explanatory.
|
|
||||||
|
|
||||||
Note: Requesting SSL Certificates won't work until this project is accessible from the outside world, as explained below.
|
Note: Requesting SSL Certificates won't work until this project is accessible from the outside world, as explained below.
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +40,8 @@ Email: admin@example.com
|
|||||||
Password: changeme
|
Password: changeme
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Immediately after logging in with this default user you will be asked to modify your details and change your password.
|
||||||
|
|
||||||
|
|
||||||
## Hosting your home network
|
## Hosting your home network
|
||||||
|
|
||||||
|
140
doc/INSTALL.md
Normal file
140
doc/INSTALL.md
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
## Installation and Configuration
|
||||||
|
|
||||||
|
There's a few ways to configure this app depending on:
|
||||||
|
|
||||||
|
- Whether you use `docker-compose` or vanilla docker
|
||||||
|
- Which Database you want to use (mysql or postgres)
|
||||||
|
- Which architecture you're running it on (raspberry pi also supported)
|
||||||
|
|
||||||
|
### Configuration File
|
||||||
|
|
||||||
|
**The configuration file needs to be provided by you!**
|
||||||
|
|
||||||
|
Don't worry, this is easy to do.
|
||||||
|
|
||||||
|
The app requires a configuration file to let it know what database you're using and where it is.
|
||||||
|
|
||||||
|
Here's an example configuration for `mysql`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"engine": "mysql",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"name": "nginxproxymanager",
|
||||||
|
"user": "nginxproxymanager",
|
||||||
|
"password": "password123",
|
||||||
|
"port": 3306
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
and here's one for `postgres`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"engine": "pg",
|
||||||
|
"version": "7.2",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"name": "nginxproxymanager",
|
||||||
|
"user": "nginxproxymanager",
|
||||||
|
"password": "password123",
|
||||||
|
"port": 5432
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you've created your configuration file it's easy to mount it in the docker container, examples below.
|
||||||
|
|
||||||
|
**Note:** After the first run of the application, the config file will be altered to include generated encryption keys unique to your installation. These keys
|
||||||
|
affect the login and session management of the application. If these keys change for any reason, all users will be logged out.
|
||||||
|
|
||||||
|
|
||||||
|
### Database
|
||||||
|
|
||||||
|
This app doesn't come with a database, you have to provide one yourself. Currently `mysql` and `postgres` databases are supported.
|
||||||
|
|
||||||
|
It's easy to use another docker container for your database also and link it as part of the docker stack. Here's an example:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: jc21/nginx-proxy-manager:2
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/app/config/production.json
|
||||||
|
- ./data:/data
|
||||||
|
- ./letsencrypt:/etc/letsencrypt
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
db:
|
||||||
|
image: mariadb
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "password123"
|
||||||
|
MYSQL_DATABASE: "nginxproxymanager"
|
||||||
|
MYSQL_USER: "nginxproxymanager"
|
||||||
|
MYSQL_PASSWORD: "password123"
|
||||||
|
volumes:
|
||||||
|
- ./data/mysql:/var/lib/mysql
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Running the App
|
||||||
|
|
||||||
|
Via `docker-compose`:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: jc21/nginx-proxy-manager:2
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/app/config/production.json
|
||||||
|
- ./data:/data
|
||||||
|
- ./letsencrypt:/etc/letsencrypt
|
||||||
|
```
|
||||||
|
|
||||||
|
Vanilla Docker:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name nginx-proxy-manager \
|
||||||
|
--network host \
|
||||||
|
-v /path/to/config.json:/app/config/production.json \
|
||||||
|
-v /path/to/data:/data \
|
||||||
|
-v /path/to/letsencrypt:/etc/letsencrypt \
|
||||||
|
jc21/nginx-proxy-manager:2
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Running on Raspberry PI / `armhf`
|
||||||
|
|
||||||
|
I have created a `armhf` docker container just for you. There may be issues with it,
|
||||||
|
if you have issues please report them here.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Postgres:
|
||||||
|
docker run -d \
|
||||||
|
--name nginx-proxy-manager-db \
|
||||||
|
--network host \
|
||||||
|
-e POSTGRES_DB=nginxproxymanager \
|
||||||
|
-e POSTGRES_USER=nginxproxymanager \
|
||||||
|
-e POSTGRES_PASSWORD=password123 \
|
||||||
|
-v /path/to/postgresql:/var/lib/postgresql/data \
|
||||||
|
zsoltm/postgresql-armhf
|
||||||
|
|
||||||
|
# NPM:
|
||||||
|
docker run -d \
|
||||||
|
--name nginx-proxy-manager-app \
|
||||||
|
--network host \
|
||||||
|
-v /path/to/config.json:/app/config/production.json \
|
||||||
|
-v /path/to/data:/data \
|
||||||
|
-v /path/to/letsencrypt:/etc/letsencrypt \
|
||||||
|
jc21/nginx-proxy-manager:2-armhf
|
||||||
|
```
|
10
doc/example/config.json
Normal file
10
doc/example/config.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"engine": "mysql",
|
||||||
|
"host": "db",
|
||||||
|
"name": "nginxproxymanager",
|
||||||
|
"user": "nginxproxymanager",
|
||||||
|
"password": "password123",
|
||||||
|
"port": 3306
|
||||||
|
}
|
||||||
|
}
|
22
doc/example/docker-compose.yml
Normal file
22
doc/example/docker-compose.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: jc21/nginx-proxy-manager:2
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/app/config/production.json
|
||||||
|
- ./data:/data
|
||||||
|
- ./letsencrypt:/etc/letsencrypt
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
db:
|
||||||
|
image: mariadb
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "password123"
|
||||||
|
MYSQL_DATABASE: "nginxproxymanager"
|
||||||
|
MYSQL_USER: "nginxproxymanager"
|
||||||
|
MYSQL_PASSWORD: "password123"
|
||||||
|
volumes:
|
||||||
|
- ./data/mysql:/var/lib/mysql
|
@ -3,4 +3,4 @@
|
|||||||
mkdir -p /data/letsencrypt-acme-challenge
|
mkdir -p /data/letsencrypt-acme-challenge
|
||||||
|
|
||||||
cd /srv/app
|
cd /srv/app
|
||||||
node --abort_on_uncaught_exception --max_old_space_size=250 /srv/app/src/backend/index.js
|
node --abort_on_uncaught_exception --max_old_space_size=250 /app/src/backend/index.js
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let config = require('config');
|
const config = require('config');
|
||||||
|
|
||||||
if (!config.has('database')) {
|
if (!config.has('database')) {
|
||||||
throw new Error('Database config does not exist! Read the README for instructions.');
|
throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md');
|
||||||
}
|
}
|
||||||
|
|
||||||
let knex = require('knex')({
|
let data = {
|
||||||
client: config.database.engine,
|
client: config.database.engine,
|
||||||
connection: {
|
connection: {
|
||||||
host: config.database.host,
|
host: config.database.host,
|
||||||
@ -18,6 +18,10 @@ let knex = require('knex')({
|
|||||||
migrations: {
|
migrations: {
|
||||||
tableName: 'migrations'
|
tableName: 'migrations'
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports = knex;
|
if (typeof config.database.version !== 'undefined') {
|
||||||
|
data.version = config.database.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('knex')(data);
|
||||||
|
@ -2,20 +2,14 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = require('config');
|
|
||||||
const app = require('./app');
|
|
||||||
const logger = require('./logger').global;
|
const logger = require('./logger').global;
|
||||||
const migrate = require('./migrate');
|
|
||||||
const setup = require('./setup');
|
|
||||||
const apiValidator = require('./lib/validator/api');
|
|
||||||
|
|
||||||
let port = process.env.PORT || 81;
|
|
||||||
|
|
||||||
if (config.has('port')) {
|
|
||||||
port = config.get('port');
|
|
||||||
}
|
|
||||||
|
|
||||||
function appStart () {
|
function appStart () {
|
||||||
|
const migrate = require('./migrate');
|
||||||
|
const setup = require('./setup');
|
||||||
|
const app = require('./app');
|
||||||
|
const apiValidator = require('./lib/validator/api');
|
||||||
|
|
||||||
return migrate.latest()
|
return migrate.latest()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return setup();
|
return setup();
|
||||||
@ -24,8 +18,8 @@ function appStart () {
|
|||||||
return apiValidator.loadSchemas;
|
return apiValidator.loadSchemas;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = app.listen(port, () => {
|
const server = app.listen(81, () => {
|
||||||
logger.info('PID ' + process.pid + ' listening on port ' + port + ' ...');
|
logger.info('PID ' + process.pid + ' listening on port 81 ...');
|
||||||
|
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', () => {
|
||||||
logger.info('PID ' + process.pid + ' received SIGTERM');
|
logger.info('PID ' + process.pid + ' received SIGTERM');
|
||||||
@ -42,4 +36,9 @@ function appStart () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
appStart();
|
try {
|
||||||
|
appStart();
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user