phpmyadmin错误The plain HTTP request was sent to HTTPS port

今天在配置nginx的https支持,把phpmyadmin放在一个子目录下,即https://ip/phpmyadmin,登录出现The plain HTTP request was sent to HTTPS port错误,现给出解决方法:
1.在location ~ \.php$区域添加fastcgi_param HTTPS on;如以下代码:

  1. location ~ \.php$ {
  2.                 fastcgi_index index.php;
  3.                 include /etc/nginx/fastcgi_params;
  4.                 fastcgi_param HTTPS on;
  5.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  6.                 fastcgi_pass 127.0.0.1:9000;
  7.         }

2.在http区域添加

  1. map $scheme $fastcgi_https {
  2. default off;
  3. https on;
  4. }

如例子:

  1. http
  2. {
  3. map $scheme $fastcgi_https {
  4. default off;
  5. https on;
  6. }
  7.  
  8.     include       /etc/nginx/mime.types;
  9.     default_type  application/octet-stream;
  10. .........
  11. }

之后重载nginx即生效.

标签:PHP 发布于:2019-11-24 17:09:20