1

The current config is:

server {
listen 80 default_server;
listen [::]:80 default_server;

listen 443 ssl default_server;
listen [::]:443 ssl default_server;

listen      192.168.0.5:80 default_server;
listen      192.168.0.5:443 ssl default_server;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /usr/share/nginx/default/ssl/default.crt;
ssl_certificate_key /usr/share/nginx/default/ssl/default.key;

server_name _;

root   /usr/share/nginx/default/www/;   
index   index.php index.html;

error_log   /usr/share/nginx/default/log/error.log;
access_log  /usr/share/nginx/default/log/access.log combined;

error_page  404 /404.html;
error_page  403     /403.html;
error_page  500 502 503 504 /50x.html;

recursive_error_pages on;
location = /404.html {
    internal;
}
location = /403.html {
    internal;
}  
location = /50x.html {
    internal;
}

location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

location ~ \.php$ {
    try_files /1a9fa3dd0cfcb3bfa9827857c25d35d7.htm @php;
}      

location @php {
try_files $uri =404;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
}

When there's an https call, before the browser verify that the certificate is valid or even available, the server redirect to the HTTP protocol.

  • do you have a reason why to do it as you described? First of all, I would split up http and https part of the config file, as your current config is messing up things. is this a production system? In my opinion you lack several ssl config parameters. I would suggest rewriting all port80 traffic to port 443. why would you want a fallback to http? if you plan on supporting encryption, I might assume you have a valid ssl cert for your server... possibly I'm misunderstanding your question. – semm0 Mar 2 '16 at 12:20
  • Hi semm0, this config accepts any domain, so no matter what HTTPs, is only one page stating that the domain isn't configured on the server. Some natural requests are https, which means that the browser issues a warning. I want the user to only view the page content without going through it. – dioo Mar 2 '16 at 12:29
  • so if you only want to display one info page, would rewriting https to http be a solution? this might me easier, as for displaying an info page no https is required. and you can then easily handle http/https requests. – semm0 Mar 2 '16 at 12:37
  • I even tried such a solution, but either the door (443 / https) was rejected for not having a certificate, or simply the browser warned for not having a valid certificate. I really hope I have done something wrong. I need a solution for this. – dioo Mar 2 '16 at 12:42
  • You might be able to do something with if ($ssl_server_name = "domain.com") {return 301 http://domain.com;} and have a check for each domain but honestly I don't think you can do what you want – Drifter104 Mar 2 '16 at 12:49
0

Just put up this condition

if ($ssl_protocol = "") {
            return 301 http://$server_name$request_uri;
    }
  • That's not what is asked. – Gerald Schneider Sep 8 '16 at 13:10
  • I have updated answer. "When there's an https call, before the browser verify that the certificate is valid or even available, the server redirect to the HTTP protocol." – Hafiz Arslan Sep 8 '16 at 14:18
  • 4
    It is not possible to send an answer before the ssl handshake with the client is complete. What the OP wants is just not possible. – Gerald Schneider Sep 8 '16 at 14:37

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.