docker - Nginx 上 HTTPS 请求的内部服务器错误
问题描述
我在 docker 中使用 nginx,我的 nginx.conf 文件如下:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html$is_args$args;
}
location /web {
alias /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/nginx.crt;
ssl_certificate_key /etc/ssl/nginx.key;
server_name localhost;
server_tokens off;
location / {
try_files $uri $uri/ /index.html$is_args$args;
}
location /web {
alias /usr/share/nginx/html;
index index.html index.htm;
}
#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
#}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
当我通过 http 加载我的网站时,我没有任何问题,但是当我通过 https 加载时,它给了我一个内部服务器错误,同时它表明连接是安全的
500 Internal Server Error
nginx
谁能指出我的配置有什么问题。
我还附上了我用来使 Nginx 工作的 Dockerfile
# build environment
FROM node:14.17.1 as builder
#more commands
# production environment
FROM nginx:stable-alpine
COPY --from=builder /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
COPY nginx.crt /etc/ssl/
COPY nginx.key /etc/ssl
EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
谢谢你的帮助
解决方案
推荐阅读
- angular - Angular 从 REST API 获取图片并显示
- sql - 该请求未通过验证基础。我不知道还能做什么((
- python - 通过 ANT 构建脚本的 Python unittest 获取 ImportError
- javascript - Mouseout,仅向上垂直移动
- wordpress - 如何打开一个wordpress网站?
- reactjs - 如何在使用 Redux (Action + Reducer) 更新数据库中的特定行后重新渲染 MaterialTable
- python - Opencv getPerspective Transform 反向点变换
- swift - SwiftUI:将窗口纵横比与子视图联系起来
- javascript - 我必须双击单元格才能将其绘制成彩色 - JavaScript
- java - 重复的 Java 构造函数(重构或生成)