我通过在我的服务器上请求php文件来收到以下消息:
400 Bad Request - 将纯HTTP请求发送到HTTPS端口。
但是只有当我想打开一个php文件时才会发生这种情况。
例如Index.html有效,但Index.php没有。
这是我的Nginx配置:
# Default server configuration
#
#Backend
upstream server_backend {
server my.domain.com:80;
server my.domain.com:443;
}
server {
listen 80;
server_name my.domain.com;
# return 301 https://$host$request_uri;
rewrite ^ https://$host$request_uri? permanent;
}
#HTTPS server
server {
listen 443 default ssl;
server_name my.domain.com;
root /usr/share/nginx/html;
autoindex on;
index index.php index.html index.htm;
#ssl on;
ssl_certificate /etc/nginx/conf.d/ssl/server.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/server.key;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 99999;
try_files $uri $uri/ /index.html;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_param https on;
#revproxy
proxy_pass http://server_backend;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /\.ht {
deny all;
}
}
E:好的,我发现它是反向代理..
但是如何同时使用反向代理和https?