【发布时间】:2021-12-08 12:50:52
【问题描述】:
我创建了一个简单的 HTML 应用程序,并尝试使用 nginx 服务器托管它。
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Test Web App!</title>
</head>
<body >
Test Web App!!!
</body>
</html>
Dockerfile
FROM nginx:latest
# Copy files and directories from the application
COPY index.html /usr/share/nginx/html
# Tell Docker we are going to use this port
EXPOSE 8080
Docker 构建
docker build -t webapp .
Docker 运行
docker run -p 8080:8080 webapp:latest
我可以使用 http://localhost:8080/ URL 运行应用程序。但我想知道我们如何将根路径更改为 http://localhost:8080/webapp URL。这意味着它应该为来自 http://localhost:8080/webapp URI 的请求提供服务正在使用 http://localhost:8080/
【问题讨论】:
标签: docker nginx nginx-reverse-proxy nginx-config