mnt-ltd / moredoc

moredoc,魔豆文库,基于golang开发的类似百度文库的开源文库系统,dochub文库的重构版本。
https://moredoc.mnt.ltd
Apache License 2.0
430 stars 105 forks source link

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

Open bluezealot opened 1 year ago

bluezealot commented 1 year ago

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

TruthHun commented 1 year ago

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

TruthHun commented 1 year ago

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

bluezealot commented 1 year ago

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

TruthHun commented 1 year ago

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

bluezealot commented 1 year ago

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

Marxss commented 1 year ago

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

bluezealot commented 1 year ago

你的意思是这个回答中的配置形式么? 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 commented 1 year ago

https://stackoverflow.com/questions/68196179/how-to-create-reverse-proxy-for-multiple-websites-in-nginx 是这个意思。