gitee.com/liu-zhao234568/cntest@v1.0.0/cmd/puppeth/wizard_nginx.go (about) 1 // Copyright 2017 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 package main 18 19 import ( 20 "fmt" 21 22 "gitee.com/liu-zhao234568/cntest/log" 23 ) 24 25 // ensureVirtualHost checks whether a reverse-proxy is running on the specified 26 // host machine, and if yes requests a virtual host from the user to host a 27 // specific web service on. If no proxy exists, the method will offer to deploy 28 // one. 29 // 30 // If the user elects not to use a reverse proxy, an empty hostname is returned! 31 func (w *wizard) ensureVirtualHost(client *sshClient, port int, def string) (string, error) { 32 proxy, _ := checkNginx(client, w.network) 33 if proxy != nil { 34 // Reverse proxy is running, if ports match, we need a virtual host 35 if proxy.port == port { 36 fmt.Println() 37 fmt.Printf("Shared port, which domain to assign? (default = %s)\n", def) 38 return w.readDefaultString(def), nil 39 } 40 } 41 // Reverse proxy is not running, offer to deploy a new one 42 fmt.Println() 43 fmt.Println("Allow sharing the port with other services (y/n)? (default = yes)") 44 if w.readDefaultYesNo(true) { 45 nocache := false 46 if proxy != nil { 47 fmt.Println() 48 fmt.Printf("Should the reverse-proxy be rebuilt from scratch (y/n)? (default = no)\n") 49 nocache = w.readDefaultYesNo(false) 50 } 51 if out, err := deployNginx(client, w.network, port, nocache); err != nil { 52 log.Error("Failed to deploy reverse-proxy", "err", err) 53 if len(out) > 0 { 54 fmt.Printf("%s\n", out) 55 } 56 return "", err 57 } 58 // Reverse proxy deployed, ask again for the virtual-host 59 fmt.Println() 60 fmt.Printf("Proxy deployed, which domain to assign? (default = %s)\n", def) 61 return w.readDefaultString(def), nil 62 } 63 // Reverse proxy not requested, deploy as a standalone service 64 return "", nil 65 }