Hello,
I am working with nginx/0.9.5, compiled with these options on a ubuntu host:
--with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module
I would like my vhost able to serve http and https requests.
This is my configuration :
server{
add_header Cache-Control "public, must-revalidate";
listen 80;
listen 443 default ssl;
error_page 404 = /templates/static/p404View.php;
client_max_body_size 10M;
root /home/daryl/mywebsite/www;
server_name daryl.mywebsite.com;
index index.php index.html maintenance.html;
ssl on;
ssl_certificate /usr/local/nginx/certificats/cert-daryl.com.crt;
ssl_certificate_key /usr/local/nginx/certificats/daryl.key;
ssl_session_timeout 5m;
access_log /home/daryl/access-daryl.log;
error_log /home/daryl/error-daryl.log;
auth_basic "UNLOL";
auth_basic_user_file /etc/htpasswd;
location / {
if (!-e $request_filename) {
rewrite .* /index.php;
}
if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)\?[0-9]+$") {
expires max;
break;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_client_abort on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
The problem is with this configuration I have an error message : 400 Bad Request
The plain HTTP request was sent to HTTPS port.
I am not certain to understand why; is nginx not able to understand the server is listening on two ports, and can serve easy http + https ?
I've read some posts about that but I do not understand, the solution say "just insert a listen 443".
In advance, thanks for help.