0

I've tried everything and I searched Google behind some solution, but can not configure SSL (https) in my Nginx server that is within a Ubuntu 14.04.2 LTS on Amazon EC2. My website works perfectly on port 80 with HTTP, but I would leave it safer adopting HTTPS.

Considerations:

  1. whenever I try to access it via https:// gives the error: ERR_CONNECTION_TIMED_OUT

  2. the command curl -v https://www.mywebsite.com/ returns: curl: (7) Failed to connect to www.mywebsite.com port 443: Connection timed out

  3. the command nc -vz localhost 443 returns: Connection to localhost 443 port [tcp/https] succeeded!

  4. the command nc -vz myserverIP 443 returns: nc: connect to myserverIP port 443 (tcp) failed: Connection timed out

  5. TCP 443 port for HTTPS are open to anywhere on Security Groups (Amazon ec2 firewall) on inbound and outbound.

  6. `netstat -ntlp | grep LISTEN:

    tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1244/proftpd: (acce tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1130/sshd tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 5633/nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5633/nginx tcp6 0 0 :::22 :::* LISTEN 1130/sshd tcp6 0 0 :::443 :::* LISTEN 5633/nginx tcp6 0 0 :::80 :::* LISTEN 5633/nginx

Nginx configurations:

  1. nginx.conf: http://pastebin.com/ebSaqabh

  2. ssl.conf (called by include of conf.d on nginx.conf): http://pastebin.com/FzVAtjGz

  3. sites-available/default:

    server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; charset utf-8; root /usr/share/nginx/html; index index.php index.html index.htm;

    server_name mywebsite.com www.mywebsite.com;
    #return 301 https://mywebsite.com$request_uri;
    #rewrite ^(.*) https://www.mywebsite.com$1 permanent;
    location / {
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php?q=$uri&$args;
            }
    
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    fastcgi_read_timeout 300;
    }
    #include /etc/nginx/common/w3tc.conf;
    include /etc/nginx/common/wordpress-seo-plugin-support.conf;
    

    }

I do not know what else to do to resolve this. Someone could help me? Do you have something wrong in my configuration of Nginx? Or need to change anything else in the Amazon?

  • Any Firewall enabled ? – krisFR May 31 '15 at 22:37
  • only the firewall of the Amazon, but the door 443 as I mentioned earlier is open. – user3416348 Jun 1 '15 at 13:39
  • The pastebins are offline, can you repaste them? – Carl Ambroselli Dec 15 '15 at 11:51
  • Your PasteBin links are broken. Please add the content here. – Eric Bolinger Oct 27 '17 at 22:17
1

Oh my... :( The Ubuntu Firewall (UFW) was activated (noob). I added ufw allow 443/tcp and now it's all right. sorry for the post. But who is riding a webserver with nginx and php-fpm can enjoy the above settings are all correct and my website is now functioning normally also with https.

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.