docker安装nginx

Updated on in 程序人生 with 0 views and 0 comments

1.拉取镜像

docker pull nginx

2.运行镜像

docker run --name nginx -d -p 10080:80 -v D:\download\docker\nginx\conf\nginx.conf:/etc/nginx/nginx.conf -v D:\download\docker\nginx\html:/etc/nginx/html -v D:\download\docker\nginx\logs:/var/log/nginx nginx

挂在的目录主要有三个,一个是conf目录,一个是nginx下的静态资源目录,还有日志

不同的nginx镜像在目录结构上可能有所差异,具体的可以先启动一个镜像,然后进入镜像查看决定要挂载的具体目录

3.nginx配置参考


#user  nobody;
worker_processes  4;

#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;

    sendfile        on;
    keepalive_timeout  65;



    server {
        listen       80;
        server_name  localhost;
    	add_header Set-Cookie "XAuthorization=$arg_token";
    	add_header Set-Cookie "Authorization=$http_authorization";
	location ~* \.(html|htm|js|css|png|gif|jpg|jpej|rar|zip|svg|json)$ {
		root   html/zzqs;
		index  index.html index.htm;
	}

	location ^~ /api/{
 		add_header backendIP $upstream_addr;
 		add_header backendCode $upstream_status;
 		proxy_pass http://10.111.106.202:8081/;
	}

	location ^~ /cBoard/{
 		add_header backendIP $upstream_addr;
 		add_header backendCode $upstream_status;
 		proxy_pass http://10.111.106.202:8080/cboard/;
 	}
 	client_max_body_size 100m;

    }





}


标题:docker安装nginx
作者:wenyl
地址:http://www.wenyoulong.com/articles/2020/05/25/1590372327381.html