1

i need set nginx respond to http and https, i configured my default conf in this way:

server {
  listen       80;
  listen       443;
  ssl           on;
  ssl_certificate       /etc/nginx/certs/domain-bundle.crt;
  ssl_certificate_key   /etc/nginx/certs/domain.it.key;
  server_name  static.domain.it;
  location / {
    try_files $uri @s3cache;
  }

  location @s3cache{
    proxy_cache            S3CACHE;
    proxy_cache_valid      200 48h;
    proxy_cache_valid      403 60m;
    proxy_pass http://static.domain.it.s3-external-3.amazonaws.com;
  }
}

The https protocol works fine, but if i go to http i have this error:

400 Bad Request The plain HTTP request was sent to HTTPS port
6

The ssl directive enables SSL for the whole vhost and does not look at the port number. If you want to restrict SSL to a single port, replace:

  listen       80;
  listen       443;
  ssl           on;

by:

  listen       80;
  listen       443 ssl;

See http://nginx.org/r/listen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.