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:
-
whenever I try to access it via
https://
gives the error:ERR_CONNECTION_TIMED_OUT
-
the command
curl -v https://www.mywebsite.com/
returns:
curl: (7) Failed to connect to www.mywebsite.com port 443: Connection timed out
-
the command
nc -vz localhost 443
returns:Connection to localhost 443 port [tcp/https] succeeded!
-
the command
nc -vz myserverIP 443
returns:
nc: connect to myserverIP port 443 (tcp) failed: Connection timed out -
TCP 443 port for HTTPS are open to anywhere on Security Groups (Amazon ec2 firewall) on inbound and outbound.
-
`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:
-
nginx.conf: http://pastebin.com/ebSaqabh
-
ssl.conf
(called by include ofconf.d
onnginx.conf
):
http://pastebin.com/FzVAtjGz -
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?
Best Answer
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.