Docker Portainer nginx 部署多端口多站点

一、nginx的部署略过

参考:docker UI管理工具portainer以及nginx的增、删、改、查配置示例

二、多端口多站点部署

1、端口配置

Docker Portainer nginx 部署多端口多站点_第1张图片

2、nginx.conf 根据安装nginx时的配置,设置对应的路径

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /root/nginx/conf/nginx/conf.d/*.conf; #多站点的配置文件存放目录与配置文件
}

Docker Portainer nginx 部署多端口多站点_第2张图片

3、修改default.conf配置

server {
    listen       9002;
    listen  [::]:9002;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
	
	add_header Content-Security-Policy "frame-ancestors localhost:8443";
      
    location / {
        try_files $uri $uri/ /index.html;
        root   /usr/share/nginx/html/aaaa;  #主站点目录
        index  index.html index.htm;
    }
}

4、增加其他站点配置,内容如下,例:aaaa.conf、bbbb.conf、cccc.conf,这些文件名根据项目情况命名。

server {
      listen       9022;
      server_name  localhost;
      add_header Content-Security-Policy "frame-ancestors localhost:8443";
	  
    location / {
        try_files $uri $uri/ /index.html;
        root   /usr/share/nginx/html/aaaa;
        index  index.html index.htm;
    }
  		
  	location /api/ {
  		proxy_pass http://localhost:9021/api/;
  	}
}

三、前两步完成后,重启nginx,即完成部署

Docker Portainer nginx 部署多端口多站点_第3张图片

你可能感兴趣的:(Docker,JAVA)