简体   繁体   English

"如何通过用户名和密码保护在 Docker 容器中运行的 Web 应用程序?"

[英]How to protect a web application running in a Docker container by username and password?

I have written a Node.js web application that gets packaged as a Docker image.我编写了一个打包为 Docker 映像的 Node.js Web 应用程序。 I can run this image, and everything is perfectly fine.我可以运行这个图像,一切都很好。

Now I would like to show the web application so someone else, so I would like to run the Docker image on a server on the internet - but I do not want it to be publicly available to everyone.现在我想向其他人展示这个 Web 应用程序,所以我想在 Internet 上的服务器上运行 Docker 映像——但我不希望它对所有人公开可用。 As a minimal level of protection I'd like to add that you need to enter your username and password - without the need to change the web application or its Docker image<\/strong> .作为最低级别的保护,我想补充一点,您需要输入用户名和密码——无需更改 Web 应用程序或其 Docker 映像<\/strong>。

How could I do this?我怎么能这样做?

One option I can think of is not to expose the Docker image at all to the public, but have a second image using eg Nginx, which then uses the Node.js image as upstream, but handles authentication before passing through.我能想到的一种选择是根本不向公众公开 Docker 映像,而是使用例如 Nginx 使用第二个映像,然后使用 Node.js 映像作为上游,但在通过之前处理身份验证。

Does this sound reasonable, or is there an easier way?这听起来合理吗,还是有更简单的方法?

"

NGINX can add HTTP basic authentication, so it should work. NGINX可以添加HTTP基本身份验证,因此它应该可以工作。

http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

这里给出了一个现成的例子: https ://github.com/beevelop/docker-nginx-basic-auth

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

相关问题 Docker - 如何查看 Docker 容器内运行应用程序的日志? - Docker - How to see the logs of running application inside Docker container? 如何通过用户名和密码保护环回资源管理器? - How can I protect the loopback explorer by username and password? 检查 React 应用程序是否在 Docker 容器中运行 - Check whether React application is running in a Docker container Docker - 如何等待容器运行 - Docker - How to wait for container running 如何使用htaccess的替代方法密码保护nodejs应用程序 - How to password protect nodejs application using alternative to htaccess 使用 web 应用程序访问另一个容器中的 docker 容器中托管的 nodejs - access nodejs hosted in docker container in another container using web application 分离运行同一Web应用程序的2个Docker容器 - Separation of 2 docker containers running the same web application 如何在docker容器中运行的nodejs应用程序内使用child_process - How to use child_process inside nodejs application running inside docker container 如何在EC2上运行Docker容器和节点应用程序? - How do I keep a Docker container and a node application running on EC2? 如何连接到在docker容器中运行的比特币testnet - How to connect to a Bitcoin testnet running in a docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM