Docker 部署 nginx 代理访问宿主机端口

环境说明

宿主机RESTful服务绑定在8090端口,nginx运行在docker。

宿主机在docker上的IP为172.18.0.1。

配置 nginx

default.conf

server {
        listen 80;

        server_name localhost;

        location /api/ {
            proxy_pass  http://172.18.0.1:8090;
        }
}

启动 docker

sudo docker run -d --name webapp -p 80:80 -v `pwd`/config:/etc/nginx/conf.d -v `pwd`/logs:/var/log/nginx nginx

登录docker虚拟机

sudo docker exec -it webapp /bin/bash

参考



blog comments powered by Disqus

Published

22 February 2017

Tags