Add Rails to nginx configs
This commit is contained in:
parent
97f6430e99
commit
ea7d96915a
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export default (domain) => {
|
||||
|
||||
const config = {};
|
||||
const namedLocation = domain[0].rails.namedLocation.computed;
|
||||
const staticRootPath = domain[0].server.path.computed + domain[0].server.documentRoot.computed;
|
||||
|
||||
config[`upstream ${domain[0].server.domain.computed}`] = {
|
||||
server: `unix:${domain[0].server.path.computed}/shared/sockets/puma.sock`,
|
||||
}
|
||||
|
||||
config['#Rails: Path for static files'] = '';
|
||||
config['root'] = `${staticRootPath}`;
|
||||
|
||||
config['# Rails: Set larger client header buffer than the default to prevent "Request header or coookie too large"'] = '';
|
||||
config['large_client_header_buffers'] = '4 16k';
|
||||
|
||||
config['# Rails: Set client max body size to 4G to prevent "413 Request Entity Too Large" '] = '';
|
||||
config['client_max_body_size'] = '4G';
|
||||
|
||||
config['# Rails: ~2 seconds is often enough for most folks to parse HTML/CSS and retrieve needed images/icons/frames, connections are cheap in nginx so increasing this is generally safe.'] = '';
|
||||
config['keepalive_timeout'] = 10;
|
||||
|
||||
config['# Rails: Error pages'] = '';
|
||||
config['error_page'] = '500 502 503 504 /500.html';
|
||||
|
||||
config['# Rails: try files'] = '';
|
||||
config['location /'] = {
|
||||
proxy_http_version: 1.1,
|
||||
try_files: `$uri/index.html $uri ${namedLocation}`
|
||||
};
|
||||
|
||||
config['# Rails: "^~ /assets/" is a "prefix string", not a regex. "^~" will prevent further location searching after this location is matched.'] = '';
|
||||
config['location ^~ /assets/'] = {
|
||||
gzip_static: 'on',
|
||||
expires: 'max',
|
||||
add_header: 'Cache-Control public',
|
||||
try_files: '$uri =404',
|
||||
error_page: '404 /404_error.html',
|
||||
};
|
||||
|
||||
config['# Rails: Set named location to be used in try_files']
|
||||
config[`location ${namedLocation} `] = {
|
||||
'proxy_set_header X-Forwarded-For': '$proxy_add_x_forwarded_for',
|
||||
'proxy_set_header X-Forwarded-Proto': 'https',
|
||||
'proxy_set_header Host': '$http_host',
|
||||
proxy_redirect: 'off',
|
||||
proxy_http_version: 1.1,
|
||||
'# If the file exists as a static file serve it directly without': '',
|
||||
'# running all the other rewrite tests on it': '',
|
||||
'if (-f $request_filename)': {
|
||||
'': 'break',
|
||||
},
|
||||
'# Check for index.html for directory index': '',
|
||||
'# if it\'s there on the filesystem then rewrite': '',
|
||||
'# the url to add /index.html to the end of it': '',
|
||||
'# and then break to send it to the next config rules.': '',
|
||||
'if (-f $request_filename/index.html)': {
|
||||
rewrite: `(.*) $1/index.html break`
|
||||
},
|
||||
'# This is the meat of the rack page caching config': '',
|
||||
'# it adds .html to the end of the url and then checks': '',
|
||||
'# the filesystem for that file. If it exists, then we': '',
|
||||
'# rewrite the url to have explicit .html on the end': '',
|
||||
'# and then send it on its way to the next config rule.': '',
|
||||
'# if there is no file on the fs then it sets all the': '',
|
||||
'# necessary headers and proxies to our upstream pumas': '',
|
||||
'if (-f $request_filename.html)': {
|
||||
rewrite: `(.*) $1.html break`
|
||||
},
|
||||
'if (!-f $request_filename)': {
|
||||
proxy_pass: `http://${domain[0].server.domain.computed}`,
|
||||
'': 'break',
|
||||
}
|
||||
};
|
||||
|
||||
// Done!
|
||||
return config;
|
||||
};
|
|
@ -33,6 +33,7 @@ import securityConf from './conf/security.conf';
|
|||
import generalConf from './conf/general.conf';
|
||||
import phpConf from './conf/php_fastcgi.conf';
|
||||
import pythonConf from './conf/python_uwsgi.conf';
|
||||
import railsConf from './conf/rails.conf';
|
||||
import proxyConf from './conf/proxy.conf';
|
||||
import wordPressConf from './conf/wordpress.conf';
|
||||
import drupalConf from './conf/drupal.conf';
|
||||
|
@ -81,6 +82,10 @@ export default (domains, global) => {
|
|||
if (domains.some(d => d.python.python.computed))
|
||||
files['nginxconfig.io/python_uwsgi.conf'] = toConf(pythonConf(global));
|
||||
|
||||
// Rails
|
||||
if (domains.some(d => d.rails.rails.computed))
|
||||
files['nginxconfig.io/rails.conf'] = toConf(railsConf(domains, global));
|
||||
|
||||
// Reverse proxy
|
||||
if (domains.some(d => d.reverseProxy.reverseProxy.computed))
|
||||
files['nginxconfig.io/proxy.conf'] = toConf(proxyConf(global));
|
||||
|
|
|
@ -35,14 +35,15 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
joomla: 'Joomla',
|
||||
django: 'Django',
|
||||
logging: 'Logging',
|
||||
reverseProxy: 'Reverse proxy',
|
||||
reverseProxyLower: 'reverse proxy',
|
||||
restrict: 'Restrict',
|
||||
path: 'Path',
|
||||
reverseProxy: 'Reverse proxy',
|
||||
reverseProxyLower: 'reverse proxy',
|
||||
restrict: 'Restrict',
|
||||
path: 'Path',
|
||||
};
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: 'Frontend',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: 'Single-page application',
|
||||
rails: 'Rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails} is disabled.`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails} cannot be enabled whilst the reverse proxy is enabled.`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails} cannot be enabled whilst ${common.php} is enabled.`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails} cannot be enabled whilst ${common.python} is enabled.`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `App named location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: 'Frontend',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: 'Application monopage',
|
||||
rails: 'Des rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails} est désactivé.`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails} ne peut pas être activé en même temps que le ${common.reverseProxyLower}.`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails} ne peut pas être activé en même temps que ${common.php}.`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails} ne peut pas être activé en même temps que ${common.python}.`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: 'Frontend',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: 'Aplikacja Single-page (SPA)',
|
||||
rails: 'Rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails} jest wyłączony.`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails} nie może zostać włączony dopóki włączony jest reverse proxy.`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails} nie może zostać włączony dopóki włączony jest ${common.php}.`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails} nie może zostać włączony dopóki włączony jest ${common.python}.`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: 'Frontend',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: 'Aplicação de página única',
|
||||
rails: 'Rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `O ${common.rails} está desabilitado.`,
|
||||
railsCannotBeEnabledWithReverseProxy: `O ${common.rails} não pode ser habilitado enquanto o proxy reverso estiver habilitado.`,
|
||||
railsCannotBeEnabledWithPhp: `O ${common.rails} não pode ser habilitado enquanto o ${common.php} estiver habilitado.`,
|
||||
railsCannotBeEnabledWithPython: `O ${common.rails} não pode ser habilitado enquanto o ${common.python} estiver habilitado.`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: 'Фронтэнд',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: 'Одностраничное приложение',
|
||||
rails: 'Рельсы',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails} выключен.`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails} не может быть включен, пока включен обратный прокси.`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails} cне может быть включен, пока включен ${common.php}.`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails} не может быть включен, пока включен ${common.python}.`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: '前端',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: '单页面应用',
|
||||
rails: 'Rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails} 已禁用。`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails}在启用${common.reverseProxy}时无法启用。`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails}在启用${common.php}时无法启用。`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails}在启用${common.python}时无法启用。`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -35,6 +35,7 @@ export default {
|
|||
https: 'HTTPS',
|
||||
letsEncrypt: 'Let\'s Encrypt',
|
||||
python: 'Python',
|
||||
rails: 'Rails',
|
||||
wordPress: 'WordPress',
|
||||
drupal: 'Drupal',
|
||||
magento: 'Magento',
|
||||
|
|
|
@ -29,10 +29,11 @@ import logging from './logging';
|
|||
import php from './php';
|
||||
import presets from './presets';
|
||||
import python from './python';
|
||||
import rails from './rails';
|
||||
import reverseProxy from './reverse_proxy';
|
||||
import routing from './routing';
|
||||
import server from './server';
|
||||
import restrict from './restrict';
|
||||
import onion from './onion';
|
||||
|
||||
export default { https, logging, php, presets, python, reverseProxy, routing, server, restrict, onion };
|
||||
export default { https, logging, php, presets, python, rails, reverseProxy, routing, server, restrict, onion };
|
||||
|
|
|
@ -30,4 +30,5 @@ export default {
|
|||
frontend: '前端',
|
||||
nodeJs: 'Node.js',
|
||||
singlePageApplication: '單頁面應用',
|
||||
rails: 'Rails',
|
||||
};
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
const namedLocation = '';
|
||||
|
||||
export default {
|
||||
railsIsDisabled: `${common.rails}已禁用。`,
|
||||
railsCannotBeEnabledWithReverseProxy: `${common.rails} 在啟用${common.reverseProxy}時無法啟用。`,
|
||||
railsCannotBeEnabledWithPhp: `${common.rails}在啟用${common.php}時無法啟用。`,
|
||||
railsCannotBeEnabledWithPython: `${common.rails}在啟用${common.python}時無法啟用。`,
|
||||
enableRails: `${common.enable} ${common.rails}`,
|
||||
namedLocation: `${namedLocation} location`,
|
||||
provideANamedLocationToSetNamedLocation: 'Provide a named location address to set the \"Named Location\" configurations for your site.',
|
||||
namedLocationExpectedToBeginWithAmpersand: 'Named location should begin with `@`.',
|
||||
};
|
|
@ -28,10 +28,11 @@ import Server from './server';
|
|||
import HTTPS from './https';
|
||||
import PHP from './php';
|
||||
import Python from './python';
|
||||
import Rails from './rails';
|
||||
import ReverseProxy from './reverse_proxy';
|
||||
import Routing from './routing';
|
||||
import Logging from './logging';
|
||||
import Restrict from './restrict';
|
||||
import Onion from './onion';
|
||||
|
||||
export default [ Server, HTTPS, PHP, Python, ReverseProxy, Routing, Logging, Restrict, Onion ];
|
||||
export default [ Server, HTTPS, PHP, Python, Rails, ReverseProxy, Routing, Logging, Restrict, Onion ];
|
||||
|
|
|
@ -170,6 +170,15 @@ THE SOFTWARE.
|
|||
&& data.php.joomlaRules.computed;
|
||||
},
|
||||
},
|
||||
rails: {
|
||||
default: false,
|
||||
display: 'common.rails', // i18n key
|
||||
enabled: true,
|
||||
computedCheck(data) {
|
||||
return data.rails.rails.computed
|
||||
&& !data.routing.root.computed;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
@ -218,6 +227,7 @@ THE SOFTWARE.
|
|||
this.$parent.resetValue('php', 'joomlaRules');
|
||||
this.$parent.resetValue('python', 'python');
|
||||
this.$parent.resetValue('python', 'djangoRules');
|
||||
this.$parent.resetValue('rails', 'rails');
|
||||
this.$parent.resetValue('reverseProxy', 'reverseProxy');
|
||||
this.$parent.resetValue('routing', 'root');
|
||||
this.$parent.resetValue('routing', 'index');
|
||||
|
@ -229,6 +239,7 @@ THE SOFTWARE.
|
|||
this.$parent.setValue('php', 'php', false);
|
||||
this.$parent.setValue('routing', 'index', 'index.html');
|
||||
this.$parent.setValue('routing', 'fallbackHtml', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'php':
|
||||
|
@ -240,33 +251,48 @@ THE SOFTWARE.
|
|||
this.$parent.setValue('python', 'python', true);
|
||||
this.$parent.setValue('python', 'djangoRules', true);
|
||||
this.$parent.setValue('routing', 'root', false);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'nodejs':
|
||||
this.$parent.setValue('php', 'php', false);
|
||||
this.$parent.setValue('reverseProxy', 'reverseProxy', true);
|
||||
this.$parent.setValue('routing', 'root', false);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'singlePageApplication':
|
||||
this.$parent.setValue('routing', 'index', 'index.html');
|
||||
this.$parent.setValue('routing', 'fallbackHtml', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'wordPress':
|
||||
this.$parent.setValue('php', 'wordPressRules', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'drupal':
|
||||
this.$parent.setValue('php', 'drupalRules', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'magento':
|
||||
this.$parent.setValue('php', 'magentoRules', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'joomla':
|
||||
this.$parent.setValue('php', 'joomlaRules', true);
|
||||
this.$parent.setValue('rails', 'rails', false);
|
||||
break;
|
||||
|
||||
case 'rails':
|
||||
this.$parent.setValue('rails', 'rails', true);
|
||||
this.$parent.setValue('php', 'php', false);
|
||||
this.$parent.setValue('python', 'python', false);
|
||||
this.$parent.setValue('python', 'djangoRules', false);
|
||||
this.$parent.setValue('routing', 'root', false);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
<!--
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!railsEnabled" class="field is-horizontal is-aligned-top">
|
||||
<div class="field-label">
|
||||
<label class="label">{{ $t('common.rails') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="text">
|
||||
{{ $t('templates.domainSections.rails.railsIsDisabled') }}
|
||||
<template v-if="$parent.$props.data.reverseProxy.reverseProxy.computed">
|
||||
<br />{{ $t('templates.domainSections.rails.railsCannotBeEnabledWithReverseProxy') }}
|
||||
</template>
|
||||
<template v-if="$parent.$props.data.php.php.computed">
|
||||
<br />{{ $t('templates.domainSections.rails.railsCannotBeEnabledWithPhp') }}
|
||||
</template>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="field is-horizontal">
|
||||
<div class="field-label">
|
||||
<label class="label">{{ $t('common.rails') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div :class="`control${railsChanged ? ' is-changed' : ''}`">
|
||||
<div class="checkbox">
|
||||
<PrettyCheck v-model="rails" class="p-default p-curve p-fill p-icon">
|
||||
<i slot="extra" class="icon fas fa-check"></i>
|
||||
{{ $t('templates.domainSections.rails.enableRails') }}
|
||||
</PrettyCheck>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal is-aligned-top">
|
||||
<div class="field-label has-margin-top">
|
||||
<label class="label">{{ $t('templates.domainSections.rails.namedLocation') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div :class="`control${namedLocationChanged ? ' is-changed' : ''}`">
|
||||
<input v-model="namedLocation" class="input" type="text" :placeholder="$props.data.namedLocation.placeholder" />
|
||||
</div>
|
||||
|
||||
<template v-if="!namedLocationChanged">
|
||||
<div class="control">
|
||||
<label class="text">
|
||||
{{ $t('templates.domainSections.rails.provideANamedLocationToSetNamedLocation') }}
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="incorrectBeginning" class="control">
|
||||
<label class="text message is-warning">
|
||||
<span class="message-body">
|
||||
{{ $t('templates.domainSections.rails.namedLocationExpectedToBeginWithAmpersand') }}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PrettyCheck from 'pretty-checkbox-vue/check';
|
||||
import delegatedFromDefaults from '../../util/delegated_from_defaults';
|
||||
import computedFromDefaults from '../../util/computed_from_defaults';
|
||||
|
||||
const defaults = {
|
||||
rails: {
|
||||
default: false,
|
||||
enabled: false,
|
||||
},
|
||||
namedLocation: {
|
||||
default: '',
|
||||
placeholder: '@my_awesome_rails_app',
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'DomainRails', // Component name
|
||||
display: 'common.rails', // Display name for tab (i18n key)
|
||||
key: 'rails', // Key for data in parent
|
||||
delegated: delegatedFromDefaults(defaults), // Data the parent will present here
|
||||
components: {
|
||||
PrettyCheck,
|
||||
},
|
||||
props: {
|
||||
data: Object, // Data delegated back to us from parent
|
||||
},
|
||||
computed: {
|
||||
...computedFromDefaults(defaults, 'rails'), // Getters & setters for the delegated data
|
||||
incorrectBeginning() {
|
||||
return this.namedLocationChanged && !this.$props.data.namedLocation.computed.startsWith('@');
|
||||
},
|
||||
hasWarnings() {
|
||||
return this.incorrectBeginning;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// If the Reverse proxy or PHP is enabled, rails will be forced off
|
||||
'$parent.$props.data': {
|
||||
handler(data) {
|
||||
// This might cause recursion, but seems not to
|
||||
if (data.reverseProxy.reverseProxy.computed || data.php.php.computed) {
|
||||
this.$props.data.rails.enabled = false;
|
||||
this.$props.data.rails.computed = false;
|
||||
} else {
|
||||
this.$props.data.rails.enabled = true;
|
||||
this.$props.data.rails.computed = this.$props.data.rails.value;
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
// Set Rails namedLocation
|
||||
'$props.data.namedLocation': {
|
||||
handler(data) {
|
||||
if (data.computed) {
|
||||
console.log(this.$props.data.namedLocation.value);
|
||||
data.computed = this.$props.data.namedLocation.value;
|
||||
return data.computed;
|
||||
} else {
|
||||
data.computed = false;
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue