Skip to content

Commit

Permalink
Require local and remote proxy port to be set separately, as well as …
Browse files Browse the repository at this point in the history
…local proxy host.
  • Loading branch information
GrahamDumpleton committed Aug 15, 2023
1 parent f2c4d9f commit f998045
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 18 additions & 4 deletions client-programs/pkg/cmd/cluster_workshop_serve_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type ClusterWorkshopServeOptions struct {
ProxyProtocol string
ProxyHost string
ProxyPort int
LocalHost string
LocalPort int
HugoPort int
Token string
Files bool
Expand Down Expand Up @@ -168,7 +170,7 @@ func (o *ClusterWorkshopServeOptions) Run() error {

// Run the proxy server and Hugo server.

return renderer.RunHugoServer(path, o.Kubeconfig, name, portal, o.ProxyPort, o.HugoPort, token, o.Files, cleanupFunc)
return renderer.RunHugoServer(path, o.Kubeconfig, name, portal, o.LocalHost, o.LocalPort, o.HugoPort, token, o.Files, cleanupFunc)
}

func (p *ProjectInfo) NewClusterWorkshopServeCmd() *cobra.Command {
Expand Down Expand Up @@ -212,19 +214,31 @@ func (p *ProjectInfo) NewClusterWorkshopServeCmd() *cobra.Command {
&o.ProxyProtocol,
"proxy-protocol",
"http",
"protocol by which the proxy will be accessed",
"protocol by which any remote proxy will be accessed",
)
c.Flags().StringVar(
&o.ProxyHost,
"proxy-host",
"localhost.$(ingress_domain)",
"host by which the proxy will be accessed",
"host by which any remote proxy will be accessed",
)
c.Flags().IntVar(
&o.ProxyPort,
"proxy-port",
10081,
"port on which the proxy service will listen",
"port on which any remote proxy service will listen",
)
c.Flags().StringVar(
&o.LocalHost,
"local-host",
"0.0.0.0",
"host on which the local proxy will be listen",
)
c.Flags().IntVar(
&o.LocalPort,
"local-port",
10081,
"port on which the local proxy will listen",
)
c.Flags().IntVar(
&o.HugoPort,
Expand Down
4 changes: 2 additions & 2 deletions client-programs/pkg/renderer/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func populateTemporaryDirectory() (string, error) {

type ServerCleanupFunc func()

func RunHugoServer(workshopRoot string, kubeconfig string, workshop string, portal string, proxyPort int, hugoPort int, token string, files bool, cleanupFunc ServerCleanupFunc) error {
func RunHugoServer(workshopRoot string, kubeconfig string, workshop string, portal string, localHost string, localPort int, hugoPort int, token string, files bool, cleanupFunc ServerCleanupFunc) error {
var err error
var tempDir string

Expand Down Expand Up @@ -599,7 +599,7 @@ func RunHugoServer(workshopRoot string, kubeconfig string, workshop string, port
http.HandleFunc("/workshop/files.tar", filesHandler)
}

portString := fmt.Sprintf("0.0.0.0:%d", proxyPort)
portString := fmt.Sprintf("%s:%d", localHost, localPort)

fmt.Println("Proxy listening on:", portString)

Expand Down

0 comments on commit f998045

Please sign in to comment.