部署wordpress https时,
先配置nginx proxy manager的域名的证书和代理,通过docker portainer stack安装

version: '3.8'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      # Mysql/Maria connection parameters:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
      MARIADB_AUTO_UPGRADE: '1'
    volumes:
      - ./mysql:/var/lib/mysql

对于nginx proxy manager其服务端口设置81:81,web服务的端口设置80:80,https服务的端口设置443:443。(这是对于云服务器而言,需要在云服务器安全组打开防火墙端口,请实现确认)

我们把wordpress的web服务端口设置成8880:80,https的服务端口设置成8888:443。因此我们直接在这里配置npm代理:Domain Names是你证书的域名;Forward Hostname是你云服务器ip地址,Forward Port是你要代理的服务端口,这里wordpress的web服务端口我们设置成8880,这里就填8880。(这里不填443服务端口也不影响,最终npm会把这个wordpress的web代理成npm自己的https的即443:443服务。

先保存一下,回到配置SSL证书,注意部分云服务器的证书只能支持单个域名,这里以阿里云为例,我们在证书页增加一个单个证书,这里查阅网上其他说明即可。

回到edit proxy host页面,在ssl certificate填写刚刚在ssl配置的和证书一致的域名。保存之。

接下来可以执行wordpress的安装了,同样采用docker portainer stack安装

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8880:80
      - 8888:443
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

作者 huntersong

沪ICP备2021012984号