zoukankan      html  css  js  c++  java
  • Nginx系列(九)——容器/微服务

    Containers/Microservices
    容器/微服务
    Using the Official NGINX Image
    docker run --name my-nginx -p 80:80 -v /path/to/content:/usr/share/nginx/html:ro -d nginx #-v本地目录映射到容器目录,使用只读模式ro。其他的也是一般是本地的在前,容器的在后


    Creating an NGINX Dockerfile
    Dockerfile:
    FROM centos:7
    # Install epel repo to get nginx and install nginx
    RUN yum -y install epel-release &&
    yum -y install nginx
    # add local configuration files into the image
    ADD /nginx-conf /etc/nginx #配置nginx配置文件
    EXPOSE 80 443 #暴露端口
    CMD ["nginx"] #启动nginx

    The directory structure looks as follows:
    .
    ├── Dockerfile
    └── nginx-conf
    ├── conf.d
    │ └── default.conf
    ├── fastcgi.conf
    ├── fastcgi_params
    ├── koi-utf
    ├── koi-win
    ├── mime.types
    ├── nginx.conf
    ├── scgi_params
    ├── uwsgi_params
    └── win-utf


    Using Environment Variables in NGINX
    配置如下
    daemon off;
    env APP_DNS;
    include /usr/share/nginx/modules/*.conf;
    ...
    http {
    perl_set $upstream_app 'sub { return $ENV{"APP_DNS"}; }'; #perl_set需要提前安装ngx_http_perl_module
    server {
    ...
    location / {
    proxy_pass https://$upstream_app;
    }
    }
    }
    相关的dockerfile
    FROM centos:7
    # Install epel repo to get nginx and install nginx
    RUN yum -y install epel-release &&
    yum -y install nginx nginx-mod-http-perl
    # add local configuration files into the image
    ADD /nginx-conf /etc/nginx
    EXPOSE 80 443
    CMD ["nginx"]

  • 相关阅读:
    handsontable合并项mergeCells应用及扩展
    handsontable的基础应用
    overflow的使用
    阿里云服务器磁盘空间扩容步骤
    使用Gitblit 在Windows2008 r2上部署Git Server(完整版)
    搭建一个基于微信公众号的信息采集功能
    js数组内置方法
    C#数组、js数组、json
    将EF项目从dbfirst转化为codefirst
    通过HttpWebRequest调用webService
  • 原文地址:https://www.cnblogs.com/biaopei/p/12953092.html
Copyright © 2011-2022 走看看