Skip to content

Instantly share code, notes, and snippets.

@ijy
Forked from glinton/portal.md
Created November 26, 2017 10:58
Show Gist options
  • Save ijy/2f1f01a1a7df88fae146862bee9057b0 to your computer and use it in GitHub Desktop.
Save ijy/2f1f01a1a7df88fae146862bee9057b0 to your computer and use it in GitHub Desktop.
Portal as an SSL terminator for `nanobox run`

Download portal for your OS.

Create a config file for portal

config.json

{
 "db-connection": "scribble:///tmp/portal",
 "log-level": "info",
 "server": true,
 "just-proxy": true
}

Start portal

sudo portal -c /tmp/portal/config.json

Create a self-signed cert to use

openssl req -x509 -newkey rsa:1024 \
-keyout /tmp/key.pem -out /tmp/cert.pem \
-days 365 -nodes \
-subj "/C=US/ST=Idaho/L=Rexburg/O=Nanobox/OU=Org/CN=localhost"

Add cert to portal

portal -i add-cert -C "$(cat /tmp/cert.pem)" -k "$(cat /tmp/key.pem)"

Start your nanobox project

nanobox run
...
+ If you run a server, access it at >> 172.19.0.5

Add your project as a target to portal

portal -i add-route -j '{"path":"/","targets":["http://172.19.0.5:8080"]}'

You may also configure the following for a portal route:

  • subdomain
  • domain
  • fwdpath
  • page

Visit your app

curl -k https://localhost

key.pem

-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMGsyAKZOrGSdVCI
C8/eBm/e68fm0wXB9iIgleohHAf2gAp1bqdn9yyAXo9m9p13alg1RSh9ZuSTaJXi
SRzFDcANq6Z+KWA1O9kzC2eOKwRMb0WiKsLGu/DDAIZlybNXqh+8DQFamgLCKop8
Inh3XAJXWia65gOEqBlpLo/F2Aq9AgMBAAECgYEAjcmbh+N8B8IsJq/izeRCnCX8
QZXoCYANXMC0X/qrVd0Nshp0zxQa7bZxA9UiWPeyoC8nmVPtPwv39jr6wZg1zo1R
v8xwwWCXHN/SOS6udxMaQ3Bzii5a6hUPMq6YMo9OyBX3UxxfiP+H3s5qAvlShPw8
DL34k1qxYft85a/C1NUCQQDkTNLcw4PR2lipxWlBAsvG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o1AwTjAdBgNVHQ4EFgQUiBXUD1dR/U75kKkzGaKDq1D0yJowHwYDVR0jBBgw
FoAUiBXUD1dR/U75kKkzGaKDq1D0yJowDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B
AQsFAAOBgQBUzg1oLAs5/oTJWhDHLmvWQCHWTeNCzjM4bxtRGdd9JYrk5+Ip7J6D
Ri9djhnR5Zhvw5DwczpHSnLkodpsVuVmScLCLGuyervtZsEI8QRAZL+ggPouiE3c
KnpOBbK9//wYcwkV9NLe7Oh4wIigrEuJ1T/uXYzcNjFntdROvl5NfQ==
-----END CERTIFICATE-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment