У меня проблемы с установкой сертификата SSL на нестандартные порты в моем веб-приложении.
У меня есть проксирование nginx для предоставления трафика моему докер-контейнеру. Я установил сертификат SSL, и он отлично работает со стандартными портами (80 и 443), но не работает с такими портами, как 8881 и 59874.
Это моя конфигурация Nginx:
server {
listen 80;
listen [::]:80;
server_name smisl.net;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
ssl_certificate /etc/ssl/smisl/smisl.crt;
ssl_certificate_key /etc/ssl/smisl/www.smisl.net.key;
server_name smisl.net;
client_max_body_size 6m;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$server_name;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:60001/;
proxy_redirect http://127.0.0.1:60001/ https://$server_name/;
}
}
А это мой конфиг докера:
version: '3.4'
services:
php:
build:
context: ./docker/php
dockerfile: Dockerfile
args:
server_uid: 1000
PHP_VERSION: ${PHP_VERSION}
environment:
DIR_SITE_CONTAINER: "${DIR_SITE_CONTAINER}"
ENV: "devel"
volumes:
- /etc/localtime:/etc/localtime/:ro
- ./logs/php/:/var/log/php
- ./logs/backup/:/backup/
- type: bind
source: "${DIR_SITE_LOCAL}"
target: "${DIR_SITE_CONTAINER}"
links:
- mysql
restart: always
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
args:
server_uid: 1000
volumes:
- ./logs/nginx:/var/log/nginx
- type: bind
source: "${DIR_SITE_LOCAL}"
target: "${DIR_SITE_CONTAINER}"
- /etc/localtime:/etc/localtime/:ro
ports:
- "60001:80"
# - "60001:443"
links:
- phpmyadmin
- php
- mysql
restart: always
mysql:
build: ./docker/mysql
volumes:
- ./DATA/db:/var/lib/mysql
- /etc/localtime:/etc/localtime/:ro
- ./logs/backup/:/backup/
ports:
- '65001:3306'
environment:
ENV: "devel"
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_USER: ${MYSQL_USER}
MYSQL_USERNAME: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
restart: always
phpmyadmin:
build: ./docker/pma
restart: always
environment:
DIR_SITE_CONTAINER: "${DIR_SITE_PMA}"
# PMA_PASSWORD: ${MYSQL_PASSWORD}
# PMA_USER: ${MYSQL_USER}
PMA_HOST: "mysql"
PMA_ARBITRARY: 1
ports:
- '8881:80'
# - '8882:443'
volumes:
- /data/certs:/etc/ssl/smisl/smisl.crt
- /data/certs:/etc/ssl/smisl/www.smisl.key
- /etc/localtime:/etc/localtime/:ro
node:
build: ./docker/nodejs
restart: always
ports:
- '59874:59874' # используем это номер порта в проекте!
volumes:
- ./logs/nodejs/:/root/.npm/_logs/
- /etc/localtime:/etc/localtime/:ro