我的自我认证证书
openssl req -x509 -nodes -new -keyout server.key -out server.crt -days 365
nginx配置文件。
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80 ;
listen [::]:80;
server_name _
}
server {
listen 443;
listen [::]:443;
server_name _;
ssl on;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
location / {
proxy_pass https://vamdemicsystem.black/;
}
}
}
Dockerfile
FROM nginx
# RUN apk add --no-cache openssl
# ドキュメントルート
COPY nginx.conf /etc/nginx/nginx.conf
# COPY default.conf /etc/nginx/conf.d/default.conf
# SSL証明書
COPY server.crt /etc/nginx/server.crt
COPY server.key /etc/nginx/server.key
EXPOSE 80 443
启动
docker build -t nginx443 .
docker run --name nginx -d -p 80:80 -p 443:443 nginx443:latest