nginx重写请求没有已知的原因

当试图使phpmyadmin在我的Nginx服务器上工作时,它会将请求https://fellowshipmedia.eu/phpmyadmin重写为https://fellowshipmedia.eu/index.php 。

我试着用'rewrite_log'和'debug'标志来读取error.log,但是日志对我来说很难理解。 我可以看到,在某个点上path的前缀被删除,但为什么?

这是nginx conf文件的一部分:

server { listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate /etc/letsencrypt/live/fellowshipmedia.eu/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/fellowshipmedia.eu/privkey.pem; include snippets/ssl-params.conf; server_name fellowshipmedia.eu; root /usr/share/nginx/html/fellowshipmediaeu/httpsdocs/; index index.php index.html index.htm ; location / { try_files $uri $uri/ /index.php?page=$uri; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } } 

这是access.log:

  86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "POST /phpmyadmin/index.php HTTP/2.0" 302 619 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" 86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "GET /index.php?token=cd06ccda9c2d36a7600e99474755558a HTTP/2.0" 404 233 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" 

这是error.log: https ://pastebin.com/0BKXVjza

这是fastcgi-php.conf:

 fastcgi_split_path_info ^(.+\.php)(/.+)$; try_files $fastcgi_script_name =404; set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info; fastcgi_index index.php; include fastcgi.conf; 

这是phpmyadminredirect初始请求到不正确的/index.php状态302.检查phpmyadmin收到正确的前缀通过FastCGI初始请求 – 这部分是从您的日志中缺less,并取决于snippets/fastcgi-php.conf内容是也从您的post中失踪。 另外检查phpmyadmin自己的设置,例如PmaAbsoluteUri。

我在这个线程中发现了另一个答案: Nginx phpmyadmin在login时redirect到/而不是/ phpmyadmin

将此添加到serverblock以帮助phpmyadminfind它的位置:

 # Phpmyadmin Configurations location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; #fastcgi_pass 127.0.0.1:9000; #fastcgi_param HTTPS on; # <-- add this line fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } # Dealing with the uppercased letters location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }