Add more environment variables for server configuration, update related section in README.md
This commit is contained in:
parent
795ea21191
commit
dfc8aeeba0
2 changed files with 59 additions and 22 deletions
33
README.md
33
README.md
|
@ -101,10 +101,27 @@ Environment variables (will overwrite other server configs)
|
||||||
| variables | example values | description |
|
| variables | example values | description |
|
||||||
| --------- | ------ | ----------- |
|
| --------- | ------ | ----------- |
|
||||||
| NODE_ENV | `production` or `development` | set current environment (will apply corresponding settings in the `config.json`) |
|
| NODE_ENV | `production` or `development` | set current environment (will apply corresponding settings in the `config.json`) |
|
||||||
| DOMAIN | `hackmd.io` | domain name |
|
|
||||||
| URL_PATH | `hackmd` | sub url path, like `www.example.com/<URL_PATH>` |
|
|
||||||
| PORT | `80` | web app port |
|
|
||||||
| DEBUG | `true` or `false` | set debug mode, show more logs |
|
| DEBUG | `true` or `false` | set debug mode, show more logs |
|
||||||
|
| HMD_DOMAIN | `hackmd.io` | domain name |
|
||||||
|
| HMD_URL_PATH | `hackmd` | sub url path, like `www.example.com/<URL_PATH>` |
|
||||||
|
| HMD_PORT | `80` | web app port |
|
||||||
|
| HMD_ALLOW_ORIGIN | `localhost, hackmd.io` | domain name whitelist (use comma to separate) |
|
||||||
|
| HMD_PROTOCOL_USESSL | `true` or `false` | set to use ssl protocol for resources path (only applied when domain is set) |
|
||||||
|
| HMD_URL_ADDPORT | `true` or `false` | set to add port on callback url (port 80 or 443 won't applied) (only applied when domain is set) |
|
||||||
|
| HMD_FACEBOOK_CLIENTID | no example | Facebook API client id |
|
||||||
|
| HMD_FACEBOOK_CLIENTSECRET | no example | Facebook API client secret |
|
||||||
|
| HMD_TWITTER_CONSUMERKEY | no example | Twitter API consumer key |
|
||||||
|
| HMD_TWITTER_CONSUMERSECRET | no example | Twitter API consumer secret |
|
||||||
|
| HMD_GITHUB_CLIENTID | no example | GitHub API client id |
|
||||||
|
| HMD_GITHUB_CLIENTSECRET | no example | GitHub API client secret |
|
||||||
|
| HMD_GITLAB_BASEURL | no example | GitLab authentication endpoint, set to use other endpoint than GitLab.com (optional) |
|
||||||
|
| HMD_GITLAB_CLIENTID | no example | GitLab API client id |
|
||||||
|
| HMD_GITLAB_CLIENTSECRET | no example | GitLab API client secret |
|
||||||
|
| HMD_DROPBOX_CLIENTID | no example | Dropbox API client id |
|
||||||
|
| HMD_DROPBOX_CLIENTSECRET | no example | Dropbox API client secret |
|
||||||
|
| HMD_GOOGLE_CLIENTID | no example | Google API client id |
|
||||||
|
| HMD_GOOGLE_CLIENTSECRET | no example | Google API client secret |
|
||||||
|
| HMD_IMGUR_CLIENTID | no example | Imgur API client id |
|
||||||
|
|
||||||
Server settings `config.json`
|
Server settings `config.json`
|
||||||
---
|
---
|
||||||
|
@ -117,8 +134,8 @@ Server settings `config.json`
|
||||||
| port | `80` | web app port |
|
| port | `80` | web app port |
|
||||||
| alloworigin | `['localhost']` | domain name whitelist |
|
| alloworigin | `['localhost']` | domain name whitelist |
|
||||||
| usessl | `true` or `false` | set to use ssl server (if true will auto turn on `protocolusessl`) |
|
| usessl | `true` or `false` | set to use ssl server (if true will auto turn on `protocolusessl`) |
|
||||||
| protocolusessl | `true` or `false` | set to use ssl protocol for resources path |
|
| protocolusessl | `true` or `false` | set to use ssl protocol for resources path (only applied when domain is set) |
|
||||||
| urladdport | `true` or `false` | set to add port on callback url (port 80 or 443 won't applied) |
|
| urladdport | `true` or `false` | set to add port on callback url (port 80 or 443 won't applied) (only applied when domain is set) |
|
||||||
| usecdn | `true` or `false` | set to use CDN resources or not |
|
| usecdn | `true` or `false` | set to use CDN resources or not |
|
||||||
| db | `{ "dialect": "sqlite", "storage": "./db.hackmd.sqlite" }` | set the db configs, [see more here](http://sequelize.readthedocs.org/en/latest/api/sequelize/) |
|
| db | `{ "dialect": "sqlite", "storage": "./db.hackmd.sqlite" }` | set the db configs, [see more here](http://sequelize.readthedocs.org/en/latest/api/sequelize/) |
|
||||||
| sslkeypath | `./cert/client.key` | ssl key path (only need when you set usessl) |
|
| sslkeypath | `./cert/client.key` | ssl key path (only need when you set usessl) |
|
||||||
|
@ -144,10 +161,10 @@ Server settings `config.json`
|
||||||
Third-party integration api key settings
|
Third-party integration api key settings
|
||||||
---
|
---
|
||||||
|
|
||||||
| service | file path | description |
|
| service | settings location | description |
|
||||||
| ------- | --------- | ----------- |
|
| ------- | --------- | ----------- |
|
||||||
| facebook, twitter, github, gitlab, dropbox, google | `config.json` | for signin |
|
| facebook, twitter, github, gitlab, dropbox, google | environment variables or `config.json` | for signin |
|
||||||
| imgur | `config.json` | for image upload |
|
| imgur | environment variables or `config.json` | for image upload |
|
||||||
| google drive, dropbox | `public/js/config.js` | for export and import |
|
| google drive, dropbox | `public/js/config.js` | for export and import |
|
||||||
|
|
||||||
Third-party integration oauth callback urls
|
Third-party integration oauth callback urls
|
||||||
|
|
|
@ -7,16 +7,17 @@ var config = require(path.join(__dirname, '..', 'config.json'))[env];
|
||||||
var debug = process.env.DEBUG ? (process.env.DEBUG === 'true') : ((typeof config.debug === 'boolean') ? config.debug : (env === 'development'));
|
var debug = process.env.DEBUG ? (process.env.DEBUG === 'true') : ((typeof config.debug === 'boolean') ? config.debug : (env === 'development'));
|
||||||
|
|
||||||
// url
|
// url
|
||||||
var domain = process.env.DOMAIN || config.domain || '';
|
var domain = process.env.DOMAIN || process.env.HMD_DOMAIN || config.domain || '';
|
||||||
var urlpath = process.env.URL_PATH || config.urlpath || '';
|
var urlpath = process.env.URL_PATH || process.env.HMD_URL_PATH || config.urlpath || '';
|
||||||
var port = process.env.PORT || config.port || 3000;
|
var port = process.env.PORT || process.env.HMD_PORT || config.port || 3000;
|
||||||
var alloworigin = config.alloworigin || ['localhost'];
|
var alloworigin = process.env.HMD_ALLOW_ORIGIN ? process.env.HMD_ALLOW_ORIGIN.split(',') : (config.alloworigin || ['localhost']);
|
||||||
|
|
||||||
var usessl = !!config.usessl;
|
var usessl = !!config.usessl;
|
||||||
var protocolusessl = (config.usessl === true && typeof config.protocolusessl === 'undefined') ? true : !!config.protocolusessl;
|
var protocolusessl = (usessl === true && typeof process.env.HMD_PROTOCOL_USESSL === 'undefined' && typeof config.protocolusessl === 'undefined')
|
||||||
var urladdport = !!config.urladdport;
|
? true : (process.env.HMD_PROTOCOL_USESSL ? (process.env.HMD_PROTOCOL_USESSL === 'true') : !!config.protocolusessl);
|
||||||
|
var urladdport = process.env.HMD_URL_ADDPORT ? (process.env.HMD_URL_ADDPORT === 'true') : !!config.urladdport;
|
||||||
|
|
||||||
var usecdn = !!config.usecdn;
|
var usecdn = process.env.HMD_USECDN ? (process.env.HMD_USECDN === 'true') : !!config.usecdn;
|
||||||
|
|
||||||
// db
|
// db
|
||||||
var db = config.db || {
|
var db = config.db || {
|
||||||
|
@ -56,13 +57,32 @@ var heartbeattimeout = config.heartbeattimeout || 5000;
|
||||||
var documentmaxlength = config.documentmaxlength || 100000;
|
var documentmaxlength = config.documentmaxlength || 100000;
|
||||||
|
|
||||||
// auth
|
// auth
|
||||||
var facebook = config.facebook || false;
|
var facebook = (process.env.HMD_FACEBOOK_CLIENTID && process.env.HMD_FACEBOOK_CLIENTSECRET) ? {
|
||||||
var twitter = config.twitter || false;
|
clientID: process.env.HMD_FACEBOOK_CLIENTID,
|
||||||
var github = config.github || false;
|
clientSecret: process.env.HMD_FACEBOOK_CLIENTSECRET
|
||||||
var gitlab = config.gitlab || false;
|
} : config.facebook || false;
|
||||||
var dropbox = config.dropbox || false;
|
var twitter = (process.env.HMD_TWITTER_CONSUMERKEY && process.env.HMD_TWITTER_CONSUMERSECRET) ? {
|
||||||
var google = config.google || false;
|
consumerKey: process.env.HMD_TWITTER_CONSUMERKEY,
|
||||||
var imgur = config.imgur || false;
|
consumerSecret: process.env.HMD_TWITTER_CONSUMERSECRET
|
||||||
|
} : config.twitter || false;
|
||||||
|
var github = (process.env.HMD_GITHUB_CLIENTID && process.env.HMD_GITHUB_CLIENTSECRET) ? {
|
||||||
|
clientID: process.env.HMD_GITHUB_CLIENTID,
|
||||||
|
clientSecret: process.env.HMD_GITHUB_CLIENTSECRET
|
||||||
|
} : config.github || false;
|
||||||
|
var gitlab = (process.env.HMD_GITLAB_CLIENTID && process.env.HMD_GITLAB_CLIENTSECRET) ? {
|
||||||
|
baseURL: process.env.HMD_GITLAB_BASEURL,
|
||||||
|
clientID: process.env.HMD_GITLAB_CLIENTID,
|
||||||
|
clientSecret: process.env.HMD_GITLAB_CLIENTSECRET
|
||||||
|
} : config.gitlab || false;
|
||||||
|
var dropbox = (process.env.HMD_DROPBOX_CLIENTID && process.env.HMD_DROPBOX_CLIENTSECRET) ? {
|
||||||
|
clientID: process.env.HMD_DROPBOX_CLIENTID,
|
||||||
|
clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET
|
||||||
|
} : config.dropbox || false;
|
||||||
|
var google = (process.env.HMD_GOOGLE_CLIENTID && process.env.HMD_GOOGLE_CLIENTSECRET) ? {
|
||||||
|
clientID: process.env.HMD_GOOGLE_CLIENTID,
|
||||||
|
clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET
|
||||||
|
} : config.google || false;
|
||||||
|
var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false;
|
||||||
|
|
||||||
function getserverurl() {
|
function getserverurl() {
|
||||||
var url = '';
|
var url = '';
|
||||||
|
|
Loading…
Reference in a new issue