码迷,mamicode.com
首页 > 编程语言 > 详细

docker 运行jenkins及vue项目与springboot项目(四.docker运行nginx)

时间:2019-12-24 15:33:45      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:运行   host   set   eve   default   shared   list   ams   web页面   

docker 运行jenkins及vue项目与springboot项目:

准备配置

创建 /home/jenkins/docker/nginx/nginx.conf 文件及/home/docker/nginx/log文件夹
其nginx.conf 文件为在原nginx.conf上添加上自定义的一些配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    #
     upstream blog {
        server localhost:8089;
        #hash $remote_addr;
        #check interval=3000 rise=2 fall=5 timeout=1000 type=http;
        #check_http_send "HEAD /mwmonitor/check.jsp HTTP/1.0\r\n\r\n";
        # check_http_expect_alive http_2xx http_3xx;
        #                                #keepalive 60;
        #                                        ip_hash;
        }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /var/web/www;
            try_files $uri $uri/ /index.html last;
            index  index.html index.htm;
           # error_page 405 =200 http://$host$request_uri;
        }

        location /blog {
                proxy_pass http://blog;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
运行命令

若没有镜像则会自动pull镜像
docker run -p 8080:80 -v /home/docker/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/docker/nginx/log:/var/log/nginx -v /home/docker/jenkins_home/www:/var/web/www -d docker.io/nginx
其中:
-p 8080:80 将8080端口映射至docker的80端口
-v /home/docker/nginx/nginx.conf:/etc/nginx/nginx.conf 配置映射:服务器中的nginx配置映射至容器的nginx配置中
-v /home/docker/nginx/log:/var/log/nginx 日志映射
-v /home/docker/jenkins/jenkins_home/www:/var/web/www 网页文件映射:jenkins打包后的web页面文件夹映射至nginx配置的web文件夹(在配置文件中注意更改location /{root /var/web/www; ...})

访问http://192.168.37.136:8080即可看到jenkins打包的git项目后的页面

docker 运行jenkins及vue项目与springboot项目(四.docker运行nginx)

标签:运行   host   set   eve   default   shared   list   ams   web页面   

原文地址:https://www.cnblogs.com/lantuanqing/p/12073261.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!