ERGO代理 - 本地域管理的反向代理。
通過自定義的本地域,可以輕鬆地在不同端口上運行的多個應用程序的管理。
在示例中查看更多
python3 -m http.server 8800 & # launch a web server listening on 8800
echo " http://localhost:8800 mylocalsite " > .ergo # adds a service "mylocalsite" to ergo
ergo local & # it may need sudo since it binds to port 80
curl http://mylocalsite.localhost # make a HTTP request to the ergo service :) Ergo的目標是成為一個簡單的反向代理,遵循Unix哲學僅做一件事並做得很好的哲學。簡單意味著不涉及魔法。只是一個靈活的反向代理,它擴展了眾所周知的/etc/hosts聲明。
回饋
該項目正在不斷進行開發,但是它可以使用。隨時提供反饋和開放問題。歡迎所有建議和貢獻。 :)
為了獲得幫助和反饋,您可以在https://gopher.slack.com上的#ergo-proxy頻道找到我們
在本地處理多個應用程序,並且必須記住代表每個微服務的每個端口令人沮喪。我想要一種將每個服務分配一個適當的本地域的簡單方法。 ERGO解決了這個問題。
重要的是,這些是安裝ERGO的唯一官方方法。
brew tap cristianoliveira/tap
brew install ergo
安裝最新的官方版本
curl -s https://raw.githubusercontent.com/cristianoliveira/ergo/master/install.sh | sh
或安裝特定版本
curl -s https://raw.githubusercontent.com/cristianoliveira/ergo/master/install.sh v0.2.5 | sh
來自Powershell Run:
Invoke-WebRequest https://raw.githubusercontent.com/cristianoliveira/ergo/master/install.ps1 -out ./install.ps1; ./install.ps1
您還可以在Release中找到Windows的可執行文件。
免責聲明:我每天使用基於UNIX的系統,因此我無法單獨測試每個構建。 :(
nix profile install ' github:cristianoliveira/nixpkgs#ergoProxy '更多示例請參見:https://github.com/cristianoliveira/nixpkgs
go install github.com/cristianoliveira/ergo
確保您的路徑中有$GOPATH/bin : export PATH=$PATH:$GOPATH/bin
ERGO在當前目錄中尋找一個.ergo文件。它必須包含遵循與/etc/hosts ( domain + space + url )相同格式的服務的名稱和URL。主要區別在於它還考慮了指定的端口。
運行ergo local它將嘗試綁定到localhost:80 ,並以“子”的方式收聽對您的服務的請求。 http://serviceone.localhost和http://servicetwo.localhost 。 (檢查示例以獲取更多)
注意:它可能需要蘇多(Sudo)綁定到端口80。
您可以通過ergo local -p <port>給它一個不同的端口,並通過http://serviceone.localhost:<port>訪問它。
您還可以在/etc/hosts中添加不同的回環,例如echo '127.0.0.1 localapp' >> /etc/hosts並運行ergo local -domain localapp以通過http://serviceone.localapp和http and http and http://servicetwo.localapp訪問您的服務。
您需要在系統網絡配置上設置http://127.0.0.1:2000/proxy.pac配置。
ERGO帶有一個設置命令,可以為您配置它。當前支持的系統是:
ergo setup < operation-system >如果發生錯誤 /行不通,請查看下面的詳細配置會話。
echo "ergoproxy http://localhost:3000" > .ergo
ergo run
現在,您應該能夠訪問: http://ergoproxy.dev 。 ERGO重定向以.dev結尾的任何內容都屬於配置的URL。
您不應使用默認的.dev域,我們建議使用.test (請參閱#58),除非您的服務支持HTTPS,並且您已經擁有證書
set ERGO_DOMAIN=.test
echo "ergoproxy http://localhost:3000" > .ergo
ergo list # you shouldn't see any quotas in the output
ergo run
現在您應該能夠訪問: http://ergoproxy.test 。 ERGO重定向以.test結尾為.TEST到配置的URL。
簡單,對嗎?不涉及魔法。
您想添加更多服務嗎?很容易,只需在.ergo中添加更多行:
echo "otherservice http://localhost:5000" >> .ergo
ergo list
ergo run
重新啟動ERGO服務器並訪問: http://otherservice.dev
ergo add otherservice http://localhost:5000是將行附加到./.ergo速記
ERGO接受不同的配置,例如在不同的port (默認值:2000)和更改domain (默認:DEV)。您可以在ERGO的幫助運行ergo -h上找到所有這些配置。
為了使用ERGO域,您需要將其設置為代理。設置http://127.0.0.1:2000/proxy.pac proxy.pac on:
Network Preferences > Advanced > Proxies > Automatic Proxy Configuration
Settings > Network and Internet > Proxy > Use setup script
在Ubuntu上
System Settings > Network > Network Proxy > Automatic
對於其他分佈,請檢查您的網絡管理器並查找代理配置。使用瀏覽器配置作為替代方案。
可以將瀏覽器配置為使用特定代理。使用此方法作為整個系統範圍配置的替代方法。
請記住,如果您在正確設置代理之前請求該站點,則必須重置瀏覽器的緩存或更改服務的名稱。在incognito Windows緩存中,默認情況下是禁用的,因此,如果您不想刪除緩存,則可以使用它們
另外,您不應該使用默認的.dev域,我們建議使用.test (請參閱#58),除非您的服務支持HTTPS,並且您已經擁有證書
退出Chrome並使用以下選項啟動它:
# Linux
$ google-chrome --proxy-pac-url=http://localhost:2000/proxy.pac
# OS X
$ open -a " Google Chrome " --args --proxy-pac-url=http://localhost:2000/proxy.pacAutomatic Proxy configuration URL並輸入值http://localhost:2000/proxy.pac以下 network.proxy.autoconfig_url > http://localhost:2000/proxy.pac
為了將ERGO用作終端上的Web代理,您必須設置http_proxy變量。 (僅適用於Linux/OSX)
export http_proxy= " http://localhost:2000 "作為替代方案,您可以在內部/resources中看到用於運行短暫設置的腳本。這些腳本僅在ergo運行時才設置代理。
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-feature最小必需的Golang版本go1.22 。我們建議使用GVM來管理您的GO版本。
然後簡單地運行:
gvm use $( cat .gvmrc ) make allmake test
make test-integration # Requires admin permission so use it carefully.麻省理工學院