mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 16:16:20 +00:00
Basic global proxy support
This commit is contained in:
parent
8983521eb0
commit
617324abee
@ -336,6 +336,11 @@ Most of the application's configurations are defined by environment. It means th
|
||||
- `host` (string): Host name. Default value: `localhost`.
|
||||
- `port` (integer): Port on which the server should be running. Default value: `1337`.
|
||||
- `autoReload` (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`
|
||||
@ -347,6 +352,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
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
{
|
||||
"host": "localhost",
|
||||
"port": 1337,
|
||||
"proxy": {
|
||||
"enabled": false
|
||||
},
|
||||
"autoReload": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
{
|
||||
"host": "localhost",
|
||||
"port": "${process.env.PORT || 1337}",
|
||||
"proxy": {
|
||||
"enabled": false
|
||||
},
|
||||
"autoReload": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
{
|
||||
"host": "localhost",
|
||||
"port": "${process.env.PORT || 1337}",
|
||||
"proxy": {
|
||||
"enabled": false
|
||||
},
|
||||
"autoReload": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
@ -320,7 +320,23 @@ module.exports.app = async function() {
|
||||
|
||||
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}`;
|
||||
|
||||
// Global proxy support settings
|
||||
this.config.proxy.enabled = get(this.config.currentEnvironment, 'server.proxy.enabled') || this.config.proxy.enabled;
|
||||
this.config.proxy.port = get(this.config.currentEnvironment, 'server.proxy.port') || this.config.proxy.port;
|
||||
this.config.proxy.host = get(this.config.currentEnvironment, 'server.proxy.host') || this.config.proxy.host;
|
||||
this.config.proxy.ssl = get(this.config.currentEnvironment, 'server.proxy.ssl') || this.config.proxy.ssl;
|
||||
|
||||
// check if proxy is enabled and use the defined settings or if false use default
|
||||
if (this.config.proxy.enabled = true) {
|
||||
if (this.config.proxy.ssl = true) {
|
||||
this.config.url = `https://${this.config.proxy.host}:${this.config.proxy.port}`;
|
||||
} else {
|
||||
this.config.url = `http://${this.config.proxy.host}:${this.config.proxy.port}`;
|
||||
}
|
||||
} else {
|
||||
this.config.url = `http://${this.config.host}:${this.config.port}`;
|
||||
}
|
||||
};
|
||||
|
||||
const enableHookNestedDependencies = function (name, flattenHooksConfig, force = false) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user