-2

I want to create redirection rule for my site,

i want to redirect my site from ip to domain, but its working fine in non-https , but when i type https://id-address it opens as it is, no redirection.

here is my conf file.

    # HTTP server

    server {
        listen       80;
       server_name  localhost;

       #include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";

      include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";


}
    # HTTPS server

    server {
       listen       443 ssl;
       server_name  example.com;

    ssl_certificate example.com.crt;
    ssl_certificate_key example.com.key;

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;

       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;

       #include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";

       include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";

    }

    include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-vhosts.conf";



# Status
server {
    listen 80;
    server_name local-stackdriver-agent.stackdriver.com;
    location /nginx_status {
      stub_status on;
      access_log   off;
      allow 127.0.0.1;
      deny all;
    }
    location / {
      root /dev/null;
    }
}

server {
    server_name 123.456.789.100  www.example.com example.com;
    return 301 https://example.com$request_uri;
}

closed as unclear what you're asking by Tim, kasperd, Ward, kubanczyk, Dave M Apr 26 '18 at 18:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You have a lot of server blocks, but only one processing requests for https. You could set up a catch-all server block, for an example see this answer. – Richard Smith Apr 21 '18 at 11:00
  • hello, all i want is redirect from "example.com" , "123.456.789.457" to "example.com" – Jay Kapoor Apr 21 '18 at 11:26
  • 1
    To redirect a web browser has to connect to the web server. To connect https there needs to be a certificate for that domain or IP, otherwise instead of a redirect the browser will just show a security warning or error. Certificates are almost never issued for IPs. You need to reconsider what you're trying to achieve. – Tim Apr 22 '18 at 9:01
1

While it's theoretically possible, you can't easily in practice create a https certificate for an IP address. If you really, really need to do this you'll find a certificate authority who will do this for you, but I suspect in most cases you're best off finding another solution or looking at your problem in a different way.

  • Just because someone doesn't like my answer that doesn't mean it's incorrect. – Tim Apr 21 '18 at 23:30

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