小言_互联网的博客

【云原生之Docker实战】使用Docker部署反向代理 Nginx Proxy Manager

603人阅读  评论(0)

一、 Nginx Proxy Manager介绍

1. Nginx Proxy Manager介绍

Nginx Proxy Manager是用于管理 Nginx代理主机的 Docker容器,具有简单、强大的界面。它使您可以轻松地转发到您在家里或其他地方运行的网站,包括免费的 SSL,而无需对 Nginx或 Letsencrypt了解太多。

2.Nginx Proxy Manager特点

1.非常适合小白新手使用反向代理功能。
2.有一个漂亮的UI界面,使得使用简单。
3.一分钟可以搞定反向代理+SSL证书申请配置。
4.Docker-compose 一键部署,方便快捷。
5.很容易配置端口转发、404主页、重定向等功能。
6.支持多用户管理。
7.方便管理域名白名单,更好保护局域网的主机及服务器。
8.支持Nginx的深度修改,适合资深工程师玩转。

二、检查docker状态

[root@master npm]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:03:33 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.1
  GitCommit:        10f428dac7cec44c864e1b830a4623af27a9fc70
 runc:
  Version:          1.1.0
  GitCommit:        v1.1.0-0-g067aaf85
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


 

三、安装docker-compose

1.安装docker-compose

 curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

2.给docker-compose文件添加执行权限

chmod +x /usr/local/bin/docker-compose 

3.查看docker-compose版本

[root@master npm]# docker-compose -version
docker-compose version 1.25.0, build 0a186604

四、编辑docker-compose.yaml文件

1.编辑yaml安装文件

[root@master npm]# cat docker-compose.yaml 
version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    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:
      DB_MYSQL_HOST: "192.168.3.146"
      DB_MYSQL_PORT: 3671
      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: always
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    ports:
      - 3671:3306
    volumes:
      - ./data/mysql:/var/lib/mysql


 

2.创建挂载目录

[root@master npm]# mkdir -p ./data
[root@master npm]# mkdir -p ./letsencrypt
[root@master npm]# mkdir -p ./data/mysql

3.安装Nginx Proxy Manager

[root@master npm]# docker-compose up -d
Creating network "npm_default" with the default driver
Pulling db (jc21/mariadb-aria:latest)...
latest: Pulling from jc21/mariadb-aria
df20fa9351a1: Pull complete
c4e214cb7f07: Pull complete
568f83ab8cda: Pull complete
edf866f7abc9: Pull complete
a72600294fbb: Pull complete
3e879d1f1b34: Pull complete
41e2c76755f1: Pull complete
Digest: sha256:9dafab05f863cd186101fd8ac8b18684e8dfd7c3cce1376e552b77d0a8b40839
Status: Downloaded newer image for jc21/mariadb-aria:latest
Pulling app (jc21/nginx-proxy-manager:latest)...
latest: Pulling from jc21/nginx-proxy-manager
72a69066d2fe: Pull complete
825188956e90: Pull complete
6916d26329a2: Pull complete
c38d769b409b: Pull complete
1f80df406181: Pull complete
0f08d5fe2388: Pull complete
8c6f29f06fbf: Pull complete
842e56434587: Pull complete
59b65e9e8c19: Pull complete
2fa90c56d9cd: Pull complete
c34ae494dda2: Pull complete
596a4287c95c: Pull complete
93fed03147ec: Pull complete
06e5cea7a2e8: Pull complete
ed7b32089832: Pull complete
3645a0fd7712: Pull complete
3fc06797edcf: Pull complete
21b8ccd554d9: Pull complete
f1e42dc354f3: Pull complete
d2d267cd8da3: Pull complete
cdb75b136b21: Pull complete
9274cd10b66f: Pull complete
ea2bd62b2698: Pull complete
b205e981c16a: Pull complete
0dafef540f92: Pull complete
8cc9fc813fd3: Pull complete
Digest: sha256:e6d13908c87d150efc1566a9ed1570661f1c3e09362b26bfe7d7608a831e4591
Status: Downloaded newer image for jc21/nginx-proxy-manager:latest
Creating npm_db_1 ... done
Creating npm_app_1 ... done


 

4.检查安装后容器状态

[root@master npm]# docker ps |grep npm
4102171927b1   jc21/nginx-proxy-manager:latest   "/init"                  About a minute ago   Up About a minute   0.0.0.0:80-81->80-81/tcp, :::80-81->80-81/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   npm_app_1
1e1e3b72dddb   jc21/mariadb-aria:latest          "/scripts/run.sh"        About a minute ago   Up About a minute   0.0.0.0:3671->3306/tcp, :::3671->3306/tcp                                              npm_db_1
[root@master npm]# 

五、 访问Nginx Proxy Manager

1.测试Nginx Proxy Manager

2.登录web界面

http://192.168.3.146:81/login

默认的账号:admin@example.com
密码:changeme

3.打开 Nginx Proxy Manager首页


转载:https://blog.csdn.net/jks212454/article/details/125786496
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场