Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

网站根目录设置的问题 #7

Open
bluezealot opened this issue Feb 27, 2023 · 8 comments
Open

网站根目录设置的问题 #7

bluezealot opened this issue Feb 27, 2023 · 8 comments

Comments

@bluezealot
Copy link
Contributor

现在网站启动后的路径形式为
http://IP:8880
没有网站根目录,这样的话,如果部署在一个有多个子网站的nginx上的话设置子路径会非常麻烦,能否追加一段网站根目录的设置?
比如
http://IP:8880/moredoc

@TruthHun
Copy link
Contributor

dist 文件夹可以理解为根目录,存放静态文件等

@TruthHun
Copy link
Contributor

比如你在 dist 目录下,创建一个 helloworld.html,你就可以通过 http://ip:8880/helloworld.html 的方式访问。

@bluezealot
Copy link
Contributor Author

我的意思是,全网站都加上一个相对路径。
比如目前的:http://ip:8880/document http://ip:8880/uploads ...
可以配置成:http://ip:8880/moredoc/document http://ip:8880/moredoc/uploads ...
这样方便配置nginx和apache的反向代理,特别是nginx已经配置了其他站点的情况下。

@TruthHun
Copy link
Contributor

明白了。其实就是想弄成二级目录。moredoc是前后端分离的,前端用的nuxt框架,可以通过修改 nuxt.config.js 中的配置来调整实现

@bluezealot
Copy link
Contributor Author

是的,是这样一个需求。如果已经支持的话,可以修改一下使用文档,公开一下配置方法。

@Marxss
Copy link

Marxss commented Apr 3, 2023

直接在nginx上通过域名来转发,不就可以了嘛

@bluezealot
Copy link
Contributor Author

你的意思是这个回答中的配置形式么?
https://stackoverflow.com/questions/68196179/how-to-create-reverse-proxy-for-multiple-websites-in-nginx

但我们一般配置的时候是下面这种形式:
参考:https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

location /app1/ {
    proxy_bind 127.0.0.1;
    proxy_pass http://example.com/app1/;
}

location /app2/ {
    proxy_bind 127.0.0.2;
    proxy_pass http://example.com/app2/;
}

在一台WebServer(Nginx)上配置多个服务的时候最简便的是这种形式。location后面的app1就是一段二级目录。
类似的追加相对路径(relative_url)的配置方式可以在gitlab中找到
https://docs.gitlab.com/ee/install/relative_url.html

@Marxss
Copy link

Marxss commented Apr 5, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants