在我的角度应用程序中创建Docker容器时需要帮助。
Nginx配置:app.conf
root /usr/share/nginx/html;
index index.html index.htm;
server {
listen 80;
rewrite /faculty /;
location / {
gzip_static on;
proxy_cookie_path / "/; HTTPOnly; Secure";
}
location = /pipes/parsedate.pipe.js {
try_files $uri /pipes/parseDate.pipe.js;
}
location = /services/Auth.js {
try_files $uri /services/auth.js;
}
if ( $http_x_forwarded_proto != "https" ) {
return 301 https://$host$request_uri;
}
error_page 404 =200 /index.html;
}
码头工人大会
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
RUN rm -rf /usr/share/nginx/html/*
COPY nginx_conf /etc/nginx/conf.d
COPY dist/a8 /usr/share/nginx/html
VOLUME /var/log/nginx
用于运行容器的命令
docker build -t a82 -f docker_conf/Dockerfile .
docker run -d -p 80:80 a82
但是我跑步时什么也看不到http://localhost
。
请帮助,不确定是什么问题
根据您的问题,您的目录结构应如下所示:
问题是您重定向到使用HTTPS。像这样注释掉default.conf中的那些行
#if ( $http_x_forwarded_proto != "https" ) {
# return 301 https://$host$request_uri;
#}
然后,你可以达到你的index.html
使用http://localhost
。我遇到的一件事是Chrome重定向http://localhost
到了https://localhost
..但http://localhost/index.html
可以。在Edge中,仅使用即可按预期工作http://localhost
。
在所有情况下,您都可以使用来检查正确的配置curl http://localhost
。
如果要使用TLS加密,则必须向服务器提供证书。有关此信息,请参见http://nginx.org/en/docs/http/configuring_https_servers.html。然后,您也必须打开443端口[...] -p 80:80 -p 443:443 [...]
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句