diff --git a/api_auth_docker/Dockerfile b/api_auth_docker/Dockerfile index 6a534f6..ebad970 100644 --- a/api_auth_docker/Dockerfile +++ b/api_auth_docker/Dockerfile @@ -11,7 +11,7 @@ RUN apk add --update --no-cache \ su-exec COPY auth.sh /etc/nginx/conf.d/ -COPY default-ssl.conf /etc/nginx/conf.d/default.conf +COPY default.conf /etc/nginx/conf.d/default.conf COPY statuspage.html /etc/nginx/conf.d/status/ COPY entrypoint.sh entrypoint.sh COPY trace.sh /etc/nginx/conf.d/ diff --git a/api_auth_docker/default-ssl.conf b/api_auth_docker/default-ssl.conf deleted file mode 100644 index 69c7dc1..0000000 --- a/api_auth_docker/default-ssl.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 443 ssl; - server_name localhost; - - #include /etc/nginx/conf.d/ip-whitelist.conf; - - ssl_certificate /etc/ssl/certs/cert.pem; - ssl_certificate_key /etc/ssl/private/key.pem; - - location /status { - auth_basic "status"; - auth_basic_user_file conf.d/status/htpasswd; - root /etc/nginx/conf.d; - index statuspage.html; - } - - location /v0/ { - auth_request /auth; - proxy_pass http://proxy:8888/; - } - - location /auth { - internal; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME /etc/nginx/conf.d/auth.sh; - fastcgi_pass unix:/var/run/fcgiwrap.socket; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - -} diff --git a/api_auth_docker/default.conf b/api_auth_docker/default.conf index d9da37a..69c7dc1 100644 --- a/api_auth_docker/default.conf +++ b/api_auth_docker/default.conf @@ -1,9 +1,19 @@ server { - listen 80; + listen 443 ssl; server_name localhost; #include /etc/nginx/conf.d/ip-whitelist.conf; + ssl_certificate /etc/ssl/certs/cert.pem; + ssl_certificate_key /etc/ssl/private/key.pem; + + location /status { + auth_basic "status"; + auth_basic_user_file conf.d/status/htpasswd; + root /etc/nginx/conf.d; + index statuspage.html; + } + location /v0/ { auth_request /auth; proxy_pass http://proxy:8888/; diff --git a/install/generator-cyphernode/generators/app/index.js b/install/generator-cyphernode/generators/app/index.js index feca97b..62cd832 100644 --- a/install/generator-cyphernode/generators/app/index.js +++ b/install/generator-cyphernode/generators/app/index.js @@ -406,6 +406,7 @@ module.exports = class extends Generator { bitcoin_mode: 'internal', bitcoin_expose: false, lightning_expose: true, + gatekeeper_port: 443, gatekeeper_apiproperties: defaultAPIProperties, gatekeeper_ipwhitelist: '', gatekeeper_keys: { configEntries: [], clientInformation: [] }, diff --git a/install/generator-cyphernode/generators/app/prompters/010_gatekeeper.js b/install/generator-cyphernode/generators/app/prompters/010_gatekeeper.js index 9bf3321..7bc1993 100644 --- a/install/generator-cyphernode/generators/app/prompters/010_gatekeeper.js +++ b/install/generator-cyphernode/generators/app/prompters/010_gatekeeper.js @@ -39,62 +39,72 @@ module.exports = { filter: utils._trimFilter, validate: utils._notEmptyValidator }, - { - when: function( props ) { - // hacky hack - password = props.gatekeeper_clientkeyspassword; - return true; - }, - type: 'password', - name: 'gatekeeper_clientkeyspassword_c', - default: utils._getDefault( 'gatekeeper_clientkeyspassword_c' ), - message: prefix()+'Confirm your client keys password.'+utils._getHelp('gatekeeper_clientkeyspassword_c'), - filter: utils._trimFilter, - validate: function( input ) { - if(input !== password) { - throw new Error( 'Client keys passwords do not match' ); - } - return true; + { + when: function( props ) { + // hacky hack + password = props.gatekeeper_clientkeyspassword; + return true; + }, + type: 'password', + name: 'gatekeeper_clientkeyspassword_c', + default: utils._getDefault( 'gatekeeper_clientkeyspassword_c' ), + message: prefix()+'Confirm your client keys password.'+utils._getHelp('gatekeeper_clientkeyspassword_c'), + filter: utils._trimFilter, + validate: function( input ) { + if(input !== password) { + throw new Error( 'Client keys passwords do not match' ); } + return true; + } + }, + { + type: 'input', + name: 'gatekeeper_port', + default: utils._getDefault( 'gatekeeper_port' ), + message: prefix()+'The port gatekeeper will listen on for requests'+utils._getHelp('gatekeeper_port'), + filter: utils._trimFilter, + validate: function( port ) { + return utils._notEmptyValidator( port ) && !isNaN( parseInt(port) ) + } + }, + { + when: function() { return hasAuthKeys( utils.props ); }, + type: 'confirm', + name: 'gatekeeper_recreatekeys', + default: false, + message: prefix()+'Recreate gatekeeper keys?'+utils._getHelp('gatekeeper_recreatekeys') + }, + { + when: function() { return hasCert( utils.props ); }, + type: 'confirm', + name: 'gatekeeper_recreatecert', + default: false, + message: prefix()+'Recreate gatekeeper certificate?'+utils._getHelp('gatekeeper_recreatecert') + }, + { + when: function(props) { return !hasCert( utils.props ) || props.gatekeeper_recreatecert }, + type: 'input', + name: 'gatekeeper_cns', + default: utils._getDefault( 'gatekeeper_cns' ), + message: prefix()+'Gatekeeper cert CNS (ips, domains, wildcard domains seperated by comma)?'+utils._getHelp('gatekeeper_cns') + }, + { + type: 'confirm', + name: 'gatekeeper_edit_apiproperties', + default: false, + message: prefix()+'Edit API properties?'+utils._getHelp('gatekeeper_edit_apiproperties') + }, + { + when: function( props ) { + const r = props.gatekeeper_edit_apiproperties; + delete props.gatekeeper_edit_apiproperties; + return r; }, - { - when: function() { return hasAuthKeys( utils.props ); }, - type: 'confirm', - name: 'gatekeeper_recreatekeys', - default: false, - message: prefix()+'Recreate gatekeeper keys?'+utils._getHelp('gatekeeper_recreatekeys') - }, - { - when: function() { return hasCert( utils.props ); }, - type: 'confirm', - name: 'gatekeeper_recreatecert', - default: false, - message: prefix()+'Recreate gatekeeper certificate?'+utils._getHelp('gatekeeper_recreatecert') - }, - { - when: function(props) { return !hasCert( utils.props ) || props.gatekeeper_recreatecert }, - type: 'input', - name: 'gatekeeper_cns', - default: utils._getDefault( 'gatekeeper_cns' ), - message: prefix()+'Gatekeeper cert CNS (ips, domains, wildcard domains seperated by comma)?'+utils._getHelp('gatekeeper_cns') - }, - { - type: 'confirm', - name: 'gatekeeper_edit_apiproperties', - default: false, - message: prefix()+'Edit API properties?'+utils._getHelp('gatekeeper_edit_apiproperties') - }, - { - when: function( props ) { - const r = props.gatekeeper_edit_apiproperties; - delete props.gatekeeper_edit_apiproperties; - return r; - }, - type: 'editor', - name: 'gatekeeper_apiproperties', - message: utils._getHelp('gatekeeper_apiproperties')||' ', - default: utils._getDefault( 'gatekeeper_apiproperties' ) - }]; + type: 'editor', + name: 'gatekeeper_apiproperties', + message: utils._getHelp('gatekeeper_apiproperties')||' ', + default: utils._getDefault( 'gatekeeper_apiproperties' ) + }]; }, templates: function( props ) { return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem', 'htpasswd' ]; diff --git a/install/generator-cyphernode/generators/app/templates/installer/docker/docker-compose.yaml b/install/generator-cyphernode/generators/app/templates/installer/docker/docker-compose.yaml index eba5633..f6f5bf0 100644 --- a/install/generator-cyphernode/generators/app/templates/installer/docker/docker-compose.yaml +++ b/install/generator-cyphernode/generators/app/templates/installer/docker/docker-compose.yaml @@ -7,7 +7,7 @@ services: - "TRACING=1" image: cyphernode/gatekeeper:<%= gatekeeper_version %> ports: - - "443:443" + - "<%= gatekeeper_port %>:443" volumes: - "<%= gatekeeper_datapath %>/certs:/etc/ssl/certs" - "<%= gatekeeper_datapath %>/private:/etc/ssl/private" diff --git a/install/generator-cyphernode/generators/app/templates/installer/start.sh b/install/generator-cyphernode/generators/app/templates/installer/start.sh index 8fed59f..1d5bb6d 100644 --- a/install/generator-cyphernode/generators/app/templates/installer/start.sh +++ b/install/generator-cyphernode/generators/app/templates/installer/start.sh @@ -46,5 +46,5 @@ fi printf "\r\n\033[0;92mDepending on your current location and DNS settings, point your favorite browser to one of the following URLs to access Cyphernode's status page:\r\n" printf "\r\n" -printf "\033[0;95m<% cns.forEach(cn => { %><%= ('https://' + cn + '/status/\\r\\n') %><% }) %>\033[0m\r\n" +printf "\033[0;95m<% cns.forEach(cn => { %><%= ('https://' + cn + ':'+ gatekeeper_port + '/status/\\r\\n') %><% }) %>\033[0m\r\n" printf "\033[0;92mUse 'admin' as the username with the configuration password you selected at the beginning of the configuration process.\r\n\r\n\033[0m"