尝试在远程服务器上的 dockerized vite 应用程序上使用 nginx 访问安全 URL 反向代理 apache

问题描述 投票:0回答:1

好的,我会尽力详细说明我的情况。老实说,花了几天时间没有成功,但我想我可能不会太远。

所以我在远程服务器上部署了一个 vite-react 应用程序,可以通过 http://[ip]:[port]/[project name] 访问和使用该应用程序(我必须使用不同的基本 url/公共 url,因为我想使用与远程服务器关联的域的子路由来部署应用程序)。

我的服务器上正在运行其他服务。所有内容均可在 https://[domain].com/[project name] 上访问,这正是我想要对这个新项目执行的操作(我没有设置这些以前的服务)。

我们已经在端口 80 上运行 apache2,并配置了 ssl 证书等。

另一方面,该应用程序是一个 vite React 前端,它有一个运行 nginx 的生产版本来为 vite 版本生成的静态文件提供服务。 nginx 服务器来自 docker 映像,并将容器端口 80 映射到远程计算机端口 3000,因此我可以从 http://[ip]:3000/[项目名称] 访问它。

添加:

ProxyPass /project_name http://127.0.0.1:3000/project_name
ProxyPassReverse /project_name http://127.0.0.1:3000/project_name

或者

ProxyPass /project_name http://127.0.0.1:3000
ProxyPassReverse /project_name http://127.0.0.1:3000

没有像我希望的那样重定向到 https://[domain]/[project_name]。

我的 nginx 配置文件是:

server {
    listen 80;
    server_name localhost;

    location / {
        root /usr/share/nginx/html;
        index index.html;
        try_files $uri $uri/ /index.html;
    }

}

它适用于单页应用程序。

不确定我可以做什么来实现我的目标,有什么想法吗?

提前致谢。

我尝试过的一切都在描述中。向 apache 配置添加行,修改 nginx 配置...

apache http nginx https reverse-proxy
1个回答
0
投票

好吧我很蠢。请检查sites-available 文件夹中是否还有更多.conf 文件。这是其中之一,而不是默认的conf文件。

© www.soinside.com 2019 - 2024. All rights reserved.