Skip to content

Commit 4dc80ac

Browse files
committed
Add support to configure listen address
1 parent 025249c commit 4dc80ac

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ENV PC_CONFIG_PATH="" \
2929
PC_EMAIL_PORT="" \
3030
PC_EMAIL_USER="" \
3131
PC_EMAIL_PASSWORD="" \
32+
PC_LISTEN_ADDR="0.0.0.0" \
3233
PC_PORT=8080 \
3334
PC_ASSETS_PATH=${WORKDIR}/assets \
3435
PC_TLS_CERT="" \

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Starts a Padlock Cloud server instance
4949
#### Environment Variables, Flags, Configuration File Variables
5050
| Environment Variable | Flag | Configuration File | Description |
5151
|----------------------|------------------------|----------------------|----------------------------------------------|
52+
| `PC_LISTEN_ADDR` | `--listen` | `server.listen_addr` | Address to listen on |
5253
| `PC_PORT` | `--port` | `-p` | `server.port` | Port to listen on |
5354
| `PC_ASSETS_PATH` | `--assets-path` | `server.assets_path` | Path to assets directory |
5455
| `PC_TLS_CERT` | `--tls-cert` | `server.tls_cert` | Path to TLS certification file |

padlockcloud/cli.go

+7
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ func NewCliApp() *CliApp {
290290
Name: "runserver",
291291
Usage: "Starts a Padlock Cloud server instance",
292292
Flags: []cli.Flag{
293+
cli.StringFlag{
294+
Name: "listen-addr",
295+
Usage: "Address to listen on",
296+
Value: "",
297+
EnvVar: "PC_LISTEN_ADDR",
298+
Destination: &config.Server.ListenAddr,
299+
},
293300
cli.IntFlag{
294301
Name: "port, p",
295302
Usage: "Port to listen on",

padlockcloud/server.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ func (d *DataStore) Serialize() ([]byte, error) {
8282
type ServerConfig struct {
8383
// Path to assets directory; used for loading templates and such
8484
AssetsPath string `yaml:"assets_path"`
85+
// Address to listen on
86+
ListenAddr string `yaml:"listen_addr"`
8587
// Port to listen on
8688
Port int `yaml:"port"`
8789
// Path to TLS certificate
@@ -580,11 +582,12 @@ func (server *Server) Start() error {
580582

581583
server.InitHandler()
582584

585+
listenAddr := server.Config.ListenAddr
583586
port := server.Config.Port
584587
tlsCert := server.Config.TLSCert
585588
tlsKey := server.Config.TLSKey
586589

587-
server.Addr = fmt.Sprintf(":%d", port)
590+
server.Addr = fmt.Sprintf("%s:%d", listenAddr, port)
588591

589592
// Start server
590593
if tlsCert != "" && tlsKey != "" {

0 commit comments

Comments
 (0)