子目录路径上停靠的 linuxserver/dokuwiki 的 Nginx 规则

子目录路径上停靠的 linuxserver/dokuwiki 的 Nginx 规则

我可以通过输入 /dokuwiki 来访问容器,但资源和链接都混乱了。 我目前看到的

由于 PHP 包含在 dokuwiki 容器中,我不确定需要在 nginx 配置中添加什么。我已经用各种配置尝试了好几天,试图让它工作,但没有任何乐趣。无论如何,相关详细信息如下,感谢您的宝贵时间。

# Contents of nginx/nginx.conf

    user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;


    upstream docker-adguard-home {
      server adguard-home;
    }

    upstream docker-airsonic {
      server airsonic:4040;
    }

    upstream docker-dokuwiki {
      server dokuwiki;
    }

我现在将所有服务都放在 home.conf 中,一旦一切正常工作并得到强化,我打算将其拆分出来

# contents of nginx/conf/home.conf 
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        auth_basic           "Authorized users only";
        auth_basic_user_file /etc/apache2/.htpasswd;


        server_name mydomain.ddns.org 192.168.0.22;

        location /media {
                root /var/www/;
                autoindex               on;
        }

        location /adguard/ {
                proxy_cookie_path / /adguard/;
                proxy_redirect /login.html /adguard/login.html;
                proxy_pass http://docker-adguard-home/;

        }

        location /airsonic {
                proxy_set_header X-Real-IP          $remote_addr;
                proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Host   $http_host;
                proxy_set_header Host               $http_host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_max_temp_file_size            0;
                proxy_pass http://docker-airsonic;
                add_header X-Content-Type-Options "nosniff";
                add_header X-Frame-Options SAMEORIGIN;
                add_header X-XSS-Protection "1; mode=block";
                add_header X-Robots-Tag none;
        }

        location /dokuwiki/ {
                proxy_pass http://docker-dokuwiki/;
        }


        location / {
                root /var/www/html/;
                index index.html

                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

}

Docker compose 以防有人想要复制它

version: '3'
services:
  nginx: 
    image: nginx:1.17-alpine
    container_name: nginx
    restart: always
    volumes:
       - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
       - ./nginx/conf/:/etc/nginx/conf.d/:ro
       - ./nginx/htpasswd:/etc/apache2/.htpasswd:ro
       - ./log/nginx/:/var/log/nginx/
       - ./www/html/:/var/www/html/:ro
       - ./content/Music:/var/www/media/Music:ro
    ports:
      - 80:80
      - 443:443
    networks:
      - reverse-proxy

  adguard-home:
    image: adguard/adguardhome
    container_name: adguard-home
    restart: always    
    volumes:
      - ./adguard/work:/opt/adguardhome/work
      - ./adguard/config:/opt/adguardhome/conf
    ports:
      - 53:53
      - 53:53/udp
    networks:
      - reverse-proxy
    expose:
     - 80

  airsonic:
    image: linuxserver/airsonic
    container_name: airsonic
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Dublin
      - CONTEXT_PATH=/airsonic #optional
      - JAVA_OPTS=-Dserver.use-forward-headers=true
    volumes:
      - ./airsonic/config:/config
      - ./content/Music:/music:ro
      - ./airsonic/playlists:/playlists
      - ./airsonic/podcasts:/podcasts
    restart: unless-stopped
    expose:
      - 4040
    networks:
      - reverse-proxy

  dokuwiki:
    image: linuxserver/dokuwiki
    container_name: dokuwiki
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Dublin
        #- APP_URL=/dokuwiki #optional
    volumes:
      - /dokuwiki:/config
    networks:
      - reverse-proxy
    expose:
      - 80
    restart: unless-stopped

networks:
  reverse-proxy:
    driver: bridge

答案1

对于任何阅读本文的人。我最终选择了拉内托。我只需要一些东西来渲染降价。我怀疑我的问题与 php 相关,但它不再是一个问题。如果您正在寻找没有 PHP 的平面文件 wiki,请查看。

相关内容