Nginx Proxy ManagerÓëÈÝÆ÷±àÅŹ¤¾ßµÄ¼¯³É£ºÌáÉý¿ª·¢Ð§ÂÊ
Nginx Proxy ManagerÓëÈÝÆ÷±àÅŹ¤¾ßµÄ¼¯³É£ºÌáÉý¿ª·¢Ð§ÂÊ
СÐò£º
ÔÚÏÖ´úÈí¼þ¿ª·¢ÁìÓò£¬ÈÝÆ÷»¯ÊÖÒÕÒѾ³ÉΪÖ÷Á÷Ç÷ÊÆ¡£ÈÝÆ÷»¯ÊÖÒÕʹµÃÈí¼þµÄ°²ÅÅÓëÖÎÀí±äµÃÔ½·¢¼òÆӺ͸ßЧ£¬µ«Í¬Ê±Ò²´øÀ´ÁËһЩеÄÌôÕ½£¬ÀýÈçÈÝÆ÷µÄÍøÂçͨѶºÍ¸ºÔØƽºâµÈÎÊÌ⡣ΪÏàʶ¾öÕâЩÎÊÌ⣬Nginx Proxy Manager³ÉΪÁËÒ»¸öºÜºÃµÄÑ¡Ôñ¡£±¾ÎĽ«ÏÈÈÝNginx Proxy ManagerÓëÈÝÆ÷±àÅŹ¤¾ßµÄ¼¯³É£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý£¬ÒÔ×ÊÖú¿ª·¢ÕßÌáÉý¿ª·¢Ð§ÂÊ¡£
Ò»¡¢Nginx Proxy Manager¼ò½é
Nginx Proxy ManagerÊÇÒ»¸ö»ùÓÚNginxµÄ¿ªÔ´ÏîÄ¿£¬ËüÌṩÁËÒ»¸ö¼òÆÓ¶øÇ¿Ê¢µÄ½çÃ棬ÓÃÓÚÖÎÀí¶à¸öÓòÃûºÍ·´ÏòÊðÀí¹æÔò¡£Í¨¹ýNginx Proxy Manager£¬ÎÒÃÇ¿ÉÒÔÇáËɵØÉèÖúÍÖÎÀí¶à¸öÓòÃûµÄ·´ÏòÊðÀí¹æÔò£¬²¢ÊµÏÖ¸ºÔØƽºâ¡¢SSLÖÕÖ¹µÈ¹¦Ð§¡£
¶þ¡¢ÈÝÆ÷±àÅŹ¤¾ß¼ò½é
ÈÝÆ÷±àÅŹ¤¾ßÊÇÓÃÓÚ×Ô¶¯»¯ÈÝÆ÷°²ÅÅ¡¢ÖÎÀíºÍÀ©Õ¹µÄ¹¤¾ß¡£ÏÖÔÚ½ÏÁ¿³£ÓõÄÈÝÆ÷±àÅŹ¤¾ßÓÐDocker SwarmºÍKubernetes¡£ËüÃÇÄܹ»×ÊÖú¿ª·¢ÕßÇáËɵذ²ÅźÍÖÎÀí´ó¹æÄ£µÄÈÝÆ÷¼¯Èº£¬²¢ÌṩÖÖÖÖÀû±ãµÄ¹¦Ð§£¬ÀýÈçЧÀÍ·¢Ã÷¡¢¸ºÔØƽºâºÍ×Ô¶¯À©ËõÈݵȡ£
Èý¡¢Nginx Proxy ManagerÓëDocker Swarm¼¯³É
×°ÖÃDocker Swarm
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃDocker Swarm¡£ÏêϸװÖð취Çë²Î¿¼Docker¹Ù·½Îĵµ¡£
ÉèÖÃNginx Proxy ManagerЧÀÍ
ÔÚDocker SwarmÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ý±àдһ¸ödocker-compose.ymlÎļþÀ´½ç˵×ðÁú¿Ê±Ð§ÀÍ¡£ÏÂÃæÊÇÒ»¸öʾÀýµÄdocker-compose.ymlÎļþ£º
version: ‘3’
services:
nginx-proxy-manager:
image: 'jc21/nginx-proxy-manager:latest' ports: - '80:80' - '81:81' - '443:443' - '3000:3000' volumes: - '/srv/docker/nginx-proxy-manager:/data' environment: - DB_MYSQL_HOST=your_mysql_host - DB_MYSQL_PORT=your_mysql_port - DB_MYSQL_USER=your_mysql_user - DB_MYSQL_PASSWORD=your_mysql_password - DB_MYSQL_NAME=your_mysql_database deploy: replicas: 1 restart_policy: condition: any
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öʾÀýÖУ¬ÎÒÃÇʹÓÃÁËjc21/nginx-proxy-manager¾µÏñ£¬¸Ã¾µÏñ°üÀ¨ÁËNginx Proxy ManagerµÄÏà¹ØÉèÖá£ÎÒÃǽ«80¶Ë¿ÚÓ³Éäµ½ËÞÖ÷»úµÄ80¶Ë¿Ú£¬ÒÔ±ãͨ¹ýWeb½çÃæ»á¼ûNginx Proxy Manager¡£ÎÒÃÇ»¹½«443¶Ë¿ÚÓ³Éäµ½ËÞÖ÷»úµÄ443¶Ë¿Ú£¬ÒÔÖ§³ÖHTTPS¡£
ͬʱ£¬ÎÒÃǽ«/dataĿ¼ӳÉäµ½ËÞÖ÷»úµÄ/srv/docker/nginx-proxy-managerĿ¼£¬ÒԱ㳤ÆÚ»¯´æ´¢Nginx Proxy ManagerµÄÏà¹ØÊý¾Ý¡£
ÔÚenvironment²¿·Ö£¬ÎÒÃÇÐèÒªÉèÖÃMySQLÊý¾Ý¿âµÄÏà¹ØÐÅÏ¢£¬ÒÔ±ãNginx Proxy ManagerÄܹ»ÅþÁ¬ºÍÖÎÀíÊý¾Ý¿â¡£
¼¯Èº°²ÅÅ
ʹÓÃDocker Swarm£¬ÎÒÃÇ¿ÉÒÔÇáËɵؽ«Ð§ÀÍ°²Åŵ½Ò»¸ö¼¯ÈºÖС£Ïêϸ°ì·¨ÈçÏ£º
³õʼ»¯Swarm¼¯Èº£ºÖ´ÐÐdocker swarm initÏÂÁîÀ´³õʼ»¯Ò»¸öSwarm¼¯Èº¡£
°²ÅÅЧÀÍ£ºÔÚSwarm¼¯ÈºÖУ¬Ö´ÐÐdocker stack deployÏÂÁîÀ´°²ÅÅЧÀÍ£¬ÀýÈçdocker stack deploy -c docker-compose.yml nginx-proxy-manager¡£
Éó²éЧÀÍ״̬£ºÖ´ÐÐdocker service lsÏÂÁîÀ´Éó²éЧÀ͵Ä״̬¡£
À©ËõÈÝ£ºÖ´ÐÐdocker service scaleÏÂÁîÀ´À©ËõÈÝЧÀÍ£¬ÀýÈçdocker service scale nginx-proxy-manager_nginx-proxy-manager=3¡£
ËÄ¡¢Nginx Proxy ManagerÓëKubernetes¼¯³É
×°ÖÃKubernetes
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃKubernetes¡£ÏêϸװÖÃÒªÁìÇë²Î¿¼Kubernetes¹Ù·½Îĵµ¡£
ÉèÖÃNginx Proxy ManagerЧÀÍ
ÔÚKubernetesÖУ¬ÎÒÃÇʹÓÃÒ»¸öYAMLÎļþÀ´½ç˵×ðÁú¿Ê±Ð§ÀÍ¡£ÏÂÃæÊÇÒ»¸öʾÀýµÄNginx Proxy ManagerЧÀ͵ÄYAMLÎļþ£º
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-proxy-manager
spec:
replicas: 1
selector:
matchLabels: app: nginx-proxy-manager
µÇ¼ºó¸´ÖÆ
template:
metadata: labels: app: nginx-proxy-manager spec: containers: - name: nginx-proxy-manager image: jc21/nginx-proxy-manager:latest ports: - containerPort: 80 - containerPort: 81 - containerPort: 443 - containerPort: 3000 volumeMounts: - name: data mountPath: /data env: - name: DB_MYSQL_HOST value: your_mysql_host - name: DB_MYSQL_PORT value: your_mysql_port - name: DB_MYSQL_USER value: your_mysql_user - name: DB_MYSQL_PASSWORD value: your_mysql_password - name: DB_MYSQL_NAME value: your_mysql_database volumes: - name: data hostPath: path: /srv/docker/nginx-proxy-manager
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öʾÀýÖУ¬ÎÒÃǽ¨ÉèÁËÒ»¸öÃûΪnginx-proxy-managerµÄDeployment£¬Ê¹ÓÃjc21/nginx-proxy-manager¾µÏñ£¬²¢ÉèÖÃÏà¹ØµÄÇéÐαäÁ¿ºÍ¾í¡£ÏêϸµÄÉèÖÃÓëDocker SwarmÀàËÆ¡£
°²ÅÅЧÀÍ
ʹÓÃkubectlÏÂÁÎÒÃÇ¿ÉÒÔ½«Ð§ÀÍ°²Åŵ½Kubernetes¼¯ÈºÖС£Ïêϸ°ì·¨ÈçÏ£º
½¨ÉèЧÀÍ£ºÖ´ÐÐkubectl apply -f nginx-proxy-manager.yamlÏÂÁîÀ´½¨ÉèЧÀÍ¡£
Éó²éЧÀÍ״̬£ºÖ´ÐÐkubectl get deploymentsÏÂÁîÀ´Éó²éDeploymentµÄ״̬¡£
À©ËõÈÝ£ºÖ´ÐÐkubectl scale deployment nginx-proxy-manager –replicas=3ÏÂÁîÀ´À©ËõÈÝDeployment¡£
Îå¡¢×ܽá
ͨ¹ý½«Nginx Proxy ManagerÓëÈÝÆ÷±àÅŹ¤¾ß¼¯³É£¬ÎÒÃÇ¿ÉÒÔÇáËɵØÖÎÀíºÍÉèÖ÷´ÏòÊðÀí¹æÔò£¬²¢ÊµÏÖ¸ºÔØƽºâºÍSSLÖÕÖ¹µÈ¹¦Ð§¡£±¾ÎÄÌṩÁËÏêϸµÄ´úÂëʾÀý£¬×ÊÖú¿ª·¢ÕßÔÚʹÓÃNginx Proxy ManagerʱÌáÉý¿ª·¢Ð§ÂÊ¡£Í¬Ê±£¬ÎÒÃÇ»¹ÏÈÈÝÁËÓëDocker SwarmºÍKubernetesÁ½ÖÖ³£ÓõÄÈÝÆ÷±àÅŹ¤¾ßµÄ¼¯³ÉÒªÁ졣ϣÍû±¾ÎĶԿª·¢ÕßÔÚʵ¼ùÖÐÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇNginx Proxy ManagerÓëÈÝÆ÷±àÅŹ¤¾ßµÄ¼¯³É£ºÌáÉý¿ª·¢Ð§ÂʵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡