我新的nginx的,我不知道這是正常的行爲對...多個搬運工服務聽同一主機和端口
這裏是我使用的lib:https://github.com/jwilder/nginx-proxy
我會解釋這裏就是我試圖完成......
我有2個額外的服務service1
和service2
這些服務與API端點簡單的node.js圖像
service1 have routes:
- service1/api/first
- service1/api/second
`
`
service2 have routes:
- service2/api/third
- service2/api/fourth
`
So is possible to be able to access this services from same host, like this:
localhost/service1/api/first
localhost/service2/api/third
?
I tried like this:
My `docker-compose.yml` file:
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local
service1:
image: mynode:1.1
volumes:
- .:/app
restart: always
environment:
- VIRTUAL_HOST=service1.local
- VIRTUAL_PORT=8080
service2:
image: mynodeother:1.2
volumes:
- .:/app
restart: always
environment:
- VIRTUAL_HOST=service2.local
- VIRTUAL_PORT=8081
這裏是從命令docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf
生成的配置文件: http://pushsc.com/show/code/58f739790a58d602a0b99d22
而且當我在瀏覽器中查看本地主機我得到:
歡迎nginx的!
如果您看到此頁面,說明nginx web服務器已成功安裝 並正在運行。需要進一步的配置。
有關在線文檔和支持請參考nginx.org。 nginx.com提供商業支持。
感謝您使用nginx。
我用這LIB:https://github.com/jwilder/nginx-proxy生成nginx的配置文件...操作你知道它爲什麼創造了工作機會? – Vladimir
從我看到的情況來看,這是用來代理子域的,而不是路徑 –
這是什麼意思?我怎樣才能使它工作? – Vladimir