.htaccess Nginx:无法在一个codeigniter示例中加载静态资源

vbkedwbf  于 2023-01-26  发布在  Nginx
关注(0)|答案(1)|浏览(148)

我正在Docker+Nginx+Php中运行2个CodeIgniter示例(管理+公共)。
当我在浏览器上打开管理员网站时,文件/admin/application/logs/log-2023-01-23.php显示了一个错误日志:

ERROR - 2023-01-23 06:27:00 --> 404 Page Not Found: Resources/fonts
ERROR - 2023-01-23 06:27:00 --> 404 Page Not Found: Resources/css
ERROR - 2023-01-23 06:27:04 --> 404 Page Not Found: Faviconico/index

我的问题:
1.为什么/admin/resources中的所有文件夹和子文件夹都无法识别?
1.有没有办法让两个子域admin.domain.compublic.domain.com服务于文件夹adminpublic
树是这样的:

-admin
--application
--resources 
--system
--*index.php
-public
--application
--resources
--system
-sql
-*docker-compose
-*Dockerfile
-*site.conf

这是docker-compose.yml文件的外观

version: '3'
services:

  nginxall:
    depends_on:
      - database
    image: nginx:latest
    volumes:
      - ./:/public
      - ./site.conf:/etc/nginx/conf.d/default.conf
    networks: 
      codeigniter_net:
    ports:
      - "80:80"
    restart: always
  php:
    build: 
      context: ./
      dockerfile: Dockerfile
    volumes:
      - ./public:/public
      - ./admin:/admin
    depends_on:
      - database
    networks:
      codeigniter_net:

  database:
    image: mysql:5.7
    volumes:
      - ./sql/a3inf4qq_kilifair.sql:/docker-entrypoint-initdb.d/a3inf4qq_kilifair.sql
    networks:
      codeigniter_net:
    ports:
      - 3306:3306
    env_file:
      - .env

networks:
  codeigniter_net:

下面是site.conf的外观

server {
  server_name admin-site.com ;
  listen 80;
  index index.php index.html;
  root /admin;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

   # set client body size#
   client_max_body_size 8M;

  location / {
      try_files $uri /index.php?$args ;
      proxy_pass  http://admin-site.com:82;
      
  }
  location ~ \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass php:9000;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME /admin$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
  }

  location ~* \.(jpe?g|gif|png|bmp|ico|css|js|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|avi|mp\d)$ {
       access_log off;
       log_not_found off;
       try_files $uri $uri/ /admin/$uri /index.php?$args ;
       expires 1w;
   }

 
}

server {
  server_name public-site.com ;
  listen 80 ;
  index index.php index.html;
  root /public;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

   # set client body size#
   client_max_body_size 8M;

  location / {
      try_files $uri /index.php?$args ;
      proxy_pass  http://public-site.com:81;
  }
  location ~ \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass php:9000;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME /public$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
  }

  location ~* \.(jpe?g|gif|png|bmp|ico|css|js|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|avi|mp\d)$ {
       access_log off;
       log_not_found off;
       try_files $uri $uri/ /public/$uri /index.php?$args ;
       expires 1w;
   }

}
z6psavjg

z6psavjg1#

我的docker compose nginx容器有问题
我忘记在nginx.volumes中添加文件夹admin

nginxall:
    depends_on:
      - database
    image: nginx:latest
    volumes:
      - ./admin:/admin
      - ./public:/public
      - ./site.conf:/etc/nginx/conf.d/default.conf
    networks: 
      codeigniter_net:
    ports:
      - "80:80"
    restart: always

相关问题