我是 nginx 新手,我不确定这是正常行为...
这是我正在使用的库: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
这是从命令生成的配置文件:http docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf
:
//pushsc.com/show/code/58f739790a58d602a0b99d22
另外,当我在浏览器中访问 localhost 时,我得到:
欢迎使用 nginx!
如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。
有关在线文档和支持,请参阅 nginx.org。nginx.com 上提供商业支持。
感谢您使用 nginx。