我新的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