Merge branch 'master' into fix/docs-config-database

This commit is contained in:
Jim LAURIE 2018-08-30 11:55:33 +02:00 committed by GitHub
commit 0ebd0d5842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 1 deletions

View File

@ -332,6 +332,11 @@ Most of the application's configurations are defined by environment. It means th
- `port` (integer): Port on which the server should be running. Default value: `1337`.
- `autoReload`
- `enabled` (boolean): Enable or disabled server reload on files update. Default value: depends on the environment.
- `proxy`
- `enabled` (boolean): Enable proxy support such as Apache or Nginx. Default value: `false`.
- `ssl` (boolean): Enable proxy SSL support
- `host` (string): Host name your proxy service uses for Strapi.
- `port` (integer): Port that your proxy service accepts connections on.
- [`cron`](https://en.wikipedia.org/wiki/Cron)
- `enabled` (boolean): Enable or disable CRON tasks to schedule jobs at specific dates. Default value: `false`.
- `admin`
@ -343,6 +348,33 @@ Most of the application's configurations are defined by environment. It means th
- `source` (string): Define the source mode (origin, host, custom).
- `folder` (string): Indicate what the plugins folder in `host` source mode.
#### Example
**Path —** `./config/environments/**/server.json`.
As an example using this configuration with Nginx your server would respond to `https://example.com:8443` instead of `http://localhost:1337`
**Note:** you will need to configure Nginx or Apache as a proxy before configuring this example.
```json
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": true,
"ssl": true,
"host": "example.com",
"port": 8443
},
"autoReload": {
"enabled": true
},
"cron": {
"enabled": true
}
}
```
***
## Dynamic configurations

View File

@ -1,6 +1,9 @@
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": true
},

View File

@ -1,6 +1,9 @@
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},

View File

@ -1,6 +1,9 @@
{
"host": "localhost",
"port": "${process.env.PORT || 1337}",
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": false
},

View File

@ -107,6 +107,12 @@
"form.server.item.port": "Port",
"form.server.item.cron": "Cron",
"form.server.item.proxy": "Proxy Settings",
"form.server.item.proxy.enable": "Proxy Enable",
"form.server.item.proxy.ssl": "Proxy SSL",
"form.server.item.proxy.host": "Proxy Host",
"form.server.item.proxy.port": "Proxy Port",
"form.language.name": "Languages",
"form.language.description": "Configure your languages.",
"form.language.choose": "Choose a language:",

View File

@ -452,6 +452,41 @@ module.exports = {
value: _.get(strapi.config, `environments.${env}.server.cron.enabled`, null)
}
]
},
{
name: 'form.server.item.proxy',
items: [
{
name: 'form.server.item.proxy.enable',
target: 'server.proxy.enabled',
type: 'boolean',
value: _.get(strapi.config, `environments.${env}.server.proxy.enabled`, null),
items: [
{
name: 'form.server.item.proxy.host',
target: 'server.proxy.host',
type: 'string',
value: _.get(strapi.config, `environments.${env}.server.proxy.host`, null),
validations: {}
},
{
name: 'form.server.item.proxy.port',
target: 'server.proxy.port',
type: 'number',
value: _.get(strapi.config, `environments.${env}.server.proxy.port`, null),
validations: {}
},
{
name: 'form.server.item.proxy.ssl',
target: 'server.proxy.ssl',
type: 'boolean',
value: _.get(strapi.config, `environments.${env}.server.proxy.ssl`, null),
validations: {}
}
],
validations: {}
}
]
}
]
}),

View File

@ -318,9 +318,25 @@ module.exports.app = async function() {
return acc;
}, {});
// default settings
this.config.port = get(this.config.currentEnvironment, 'server.port') || this.config.port;
this.config.host = get(this.config.currentEnvironment, 'server.host') || this.config.host;
this.config.url = `http://${this.config.host}:${this.config.port}`;
// default construct url
this.config.url = `http://${this.config.host}:${this.config.port}`
// proxy settings
this.config.proxy = get(this.config.currentEnvironment, 'server.proxy' || {});
// check if SSL enabled and construct proxy url
function getProxyUrl(ssl, url) {
return `http${ssl ? 's' : ''}://${url}`;
}
// check if proxy is enabled and construct url
if (get(this.config, 'proxy.enabled')) {
this.config.url = getProxyUrl(this.config.proxy.ssl, `${this.config.proxy.host}:${this.config.proxy.port}`);
}
};
const enableHookNestedDependencies = function (name, flattenHooksConfig, force = false) {