从 v0.10 以及以上版本开发,MinDoc 支持运行在二级子目录。
要想让 MinDoc 运行在二级子目录,需要在 app.conf 配置文件中配置 baseurl 项为你的域名,例如:https://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;}}
