我想通过docker中的https运行本地应用程序。 但是仍然不知道如何。
我的docker-compose.yml:
version: '2'
services:
proxy:
build: './proxy/'
restart: always
networks:
- front-tier
depends_on:
- apache
ports:
- "8080:80"
- "443:443"
apache:
image: httpd
restart: always
ports:
- "5000"
networks:
- front-tier
networks:
front-tier:
./ proxy /中的Dockerfile:
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY certificate.crt /etc/nginx/ssl/certificate.crt
COPY certificate.key /etc/nginx/ssl/certificate.key
certificate.key和certifcate.crt由以下人员创建:
openssl req -new -x509 -nodes -sha256 -days 365 -key certificate.key -out certificate.crt
和nginx.conf:
events {
worker_processes 2;
worker_connections 1024;
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name apache.lan;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 default_server ipv6only=on;
server_name apache.lan;
ssl_certificate /etc/nginx/ssl/certificate.crt;
ssl_certificate_key /etc/nginx/ssl/certificate.key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://apache:5000;
proxy_read_timeout 90;
}
}
}
在使用此docker之后,rproxy_proxy“ nginx -g'daemon ...” 13分钟前重新启动(1)5分钟前 不断重启,当然我的https无法正常工作。有人可以帮忙吗?如何使用https在docker中启用我的网站?