Docker

子目錄路徑上停靠的 linuxserver/dokuwiki 的 Nginx 規則

  • May 1, 2020

我可以通過輸入 /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

對於任何閱讀本文的人。最後我選擇了raneto。我只需要一些東西來呈現降價。我懷疑我的問題無論如何都與 php 有關,但它不再是一個問題。如果您正在尋找沒有 PHP 的平面文件 wiki,請查看。

引用自:https://unix.stackexchange.com/questions/583576