Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度应用程序+;NGINX+;码头工人_Angular_Docker_Nginx_Web - Fatal编程技术网

Angular 角度应用程序+;NGINX+;码头工人

Angular 角度应用程序+;NGINX+;码头工人,angular,docker,nginx,web,Angular,Docker,Nginx,Web,我在docker上使用nginx提供Angular应用程序时遇到问题。 问题只是当我想在站点上打开SSL时。 我用竹子做部署 这是我的Dockerfile: FROM node:8.6 as node WORKDIR /app COPY package.json /app/ COPY ssl/certificate.crt /app/ COPY ssl/ /app/ssl RUN npm install -g @angular/cli --unsafe RUN npm install COP

我在docker上使用nginx提供Angular应用程序时遇到问题。 问题只是当我想在站点上打开SSL时。 我用竹子做部署

这是我的Dockerfile:

FROM node:8.6 as node
WORKDIR /app
COPY package.json /app/
COPY ssl/certificate.crt /app/
COPY ssl/ /app/ssl

RUN npm install -g @angular/cli --unsafe
RUN npm install

COPY ./ /app/
RUN ng build --prod --aot=false --env=prod

FROM nginx

RUN mkdir -p /ssl
COPY --from=node /app/ssl/ /ssl/
ADD ssl/certificate.crt /etc/nginx/certs/
ADD ssl/private.key /etc/nginx/certs/
RUN ls /etc/nginx/certs/

COPY --from=node /app/dist/ /usr/share/nginx/html

RUN ls /usr/share/nginx/html
要运行的脚本:

docker build -t test-app .
docker run --name test-app-cont -v /etc/nginx/certs:/etc/nginx/certs -d -p 3010:443 test-app
部署成功运行,但服务器上没有提供应用。

请查看此屏幕:列出了/certs和/html目录中的内容。一切似乎都很好

若我删除这些专用于SSL的行,一切正常,在服务器上我可以看到我的应用程序,但只能通过http

证书是有效的,我查过了


我做错了什么?

要启用SSL,需要为其配置Nginx。据我在代码中看到的,您仍然在使用默认的Nginx配置,没有任何修改。下面是一个关于的例子。主要组成部分包括:

server {

    listen 443;
    server_name jenkins.domain.com;

    ssl_certificate           /etc/nginx/cert.crt;
    ssl_certificate_key       /etc/nginx/cert.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
我还看到您在docker run命令中装载了一个卷(-v/etc/nginx/certs:/etc/nginx/certs),这意味着容器中的/etc/nginx/certs将与主机相同,因此请确保主机上有正确的证书