从 v0.10 以及以上版本开发,MinDoc支持运行在二级子目录。

要想让MinDoc运行在二级子目录,需要在app.conf配置文件中配置baseurl项为你的域名,例如:http://www.iminho.me/wiki

之后,在nginx中配置路由规则,将属于MinDoc的路由重定向到MinDoc端口。配置如下:

server {
    listen  443;
    server_name www.iminho.me;
    add_header X-Content-Type-Options nosniff;

    charset      utf-8;
    error_page 500 502 503 504 /50x.html;
    access_log  /var/log/nginx/www.iminho.me/access.log  main;
    set $root_path '/var/www/www.iminho.me/mindoc';
    root $root_path;
    try_files $uri $uri/ @rewrite;
    index index.php index.html;
    location /50x.html {
       root /var/www/html;
    }
    #此处是关键
    location /wiki/ {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;
        proxy_set_header   X-Forwarded-Proto $scheme;
        #此处配置 MinDoc 程序的地址和端口号
        proxy_pass http://127.0.0.1:8182/;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
        expires 30m;
    }
}
作者:Mindoc君  创建时间:2022-11-29 18:04
最后编辑:Mindoc君  更新时间:2023-01-09 15:02