简体   繁体   English

使用Docker设置自签名SSL反向代理时无法在Laravel项目中加载资产

[英]Can't load assets in Laravel project when setting up a self-signed SSL reverse proxy with Docker

I'm trying to setup HTTPS for my dev Laravel project, as I'd like to use Facebook login (this requires HTTPS for dev environments too now) 我想为我的开发 Laravel项目设置HTTPS,因为我想使用Facebook登录(这也要求开发环境也需要HTTPS)

I'm following this tutorial: https://medium.com/@oliver.zampieri/self-signed-ssl-reverse-proxy-with-docker-dbfc78c05b41 我正在关注本教程: https : //medium.com/@oliver.zampieri/self-signed-ssl-reverse-proxy-with-docker-dbfc78c05b41

It basically says the following: 它基本上说如下:

Create the self signed certificate: 创建自签名证书:

openssl req -subj '/CN=my-sitename.development' -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365

Find route to the host: Docker runs containers in their own sandbox, so, when the containers run in a bridged network, we need to know what is the IP address of the host (if we route to localhost or 127.0.0.1 we would proxy back into the container, instead, we need to route to the host machine) 查找到主机的路由:Docker在自己的沙箱中运行容器,因此,当容器在桥接网络中运行时,我们需要知道主机的IP地址是什么(如果我们路由到localhost或127.0.0.1,我们将代理回到容器,相反,我们需要路由到主机)

docker network inspect bridge

=> This gives us 172.17.0.1 =>这给我们172.17.0.1

Now create the NginX configuration file: 现在创建NginX配置文件:

server {
    listen 443;

    # I've added this myself
    server_name my-sitename.development;

    ssl on;
    ssl_certificate /etc/nginx/conf.d/cert.pem;
    ssl_certificate_key /etc/nginx/conf.d/key.pem;

    location / {
        proxy_pass http://172.17.0.1;
    }
}

Run the Docker container 运行Docker容器

docker run --name nginx_proxy -d -v `pwd`:/etc/nginx/conf.d -p 443:443 nginx

Last but not least I've added my created certificate in my Mac Keychain and set it to "always trust". 最后但并非最不重要的一点是,我在Mac钥匙串中添加了创建的证书,并将其设置为“始终信任”。

When I open up my (https) local site in my browser (Chrome v67), then it tells me that the certificate is valid and the website is working (I can see my site-text etc ..) except for the assets. 当我在浏览器(Chrome v67)中打开(https)本地站点时,它会告诉我证书有效且网站正在运行(我可以看到我的站点文本等。),除了资产。

The request for the assets looks like this: I don't think this can be right, but I'm not sure what to input for the proxy_pass config (see above). 对资产的请求如下所示:我认为这可能不对,但是我不确定为proxy_pass配置输入什么(请参见上文)。 Entering my-sitename.development for the proxy_pass doesn't work. 为proxy_pass输入my-sitename.development无效。 Then it redirects me to the default nginx page of the nginx_proxy docker container. 然后将我重定向到nginx_proxy docker容器的默认nginx页面。

https://172.17.0.1/css/all.css

Please note: I have another nginx docker container running to handle requests to my-sitename.development:80 请注意:我正在运行另一个Nginx Docker容器来处理对my-sitename.development:80的请求

Thanks! 谢谢!

Solved it! 解决了! Didn't need to setup the extra Docker container after all ... Could just edit the nginx config of my existing Docker container (that handled the :80 connections) 毕竟不需要设置额外的Docker容器...可以只编辑我现有Docker容器的nginx配置(处理:80连接)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Keycloak:在 docker 中为 ldaps 设置自签名证书 - Keycloak: setting up self-signed certificate for ldaps in docker Docker nginx 自签名证书 - 无法连接到 https - Docker nginx self-signed certificate - can't connect to https 如何配置 Docker for Windows 以接受自签名 SSL? - How to configure Docker for Windows to accept a self-signed SSL? Traefik和自签名SSL - Traefik and self-signed SSL 无法使用自签名证书连接到 mongodb,docker 容器中的 mongodb - Can't connect to mongodb with self-signed certificate, mongodb in docker container 无法使用 Docker 上 Web Api 核心应用程序的自签名证书连接到远程端点 - Can't connect to remote endpoint using self-signed cert from Web Api core app on Docker Docker Swarm和自签名Docker Registry - Docker Swarm and self-signed Docker Registry plesk docker 中的 Neo4j (3.4.17, 3.5.13, 4.0.0) 不使用 /ssl 中提供的 SSL 证书,而是尝试删除它们并使其自己进行自签名 - Neo4j (3.4.17, 3.5.13, 4.0.0) in docker on plesk doesn't use provided SSL certificates in /ssl but tries to delete them and make its own self-signed 如何在 docker-compose 文件中引用 traefik v2 的自签名 SSL 证书? - How do I reference a self-signed SSL certificates for traefik v2 in a docker-compose file? CircleCI中的自签名Docker注册表 - Self-signed docker registry in CircleCI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM