NginX and cert not redirecting to HTTPS

My domain is:www.habibindustry.com

My Nginx Configuration is this after running cert commands :

http://dpaste.com/1E2E2BE

Although i have redirected the HTTP to HTTPS connection my website does not work if I type www.habibindustry.com only. It works if I type https://www.habibindustry.com

I have tried many configuration but none is working. Somehow Nginx not accepting my HTTP requests. I have posted before about my website that SSL throwing error on mobile network and then I actually found out that this is the issue. I am trying for 3 hours but no luck.

what does nginx -T shows? (capitalization matter)

It shwos syntax ok. No problem at all.

Hi @Yunus0or1

it’s the same picture shared there - SSL certificate thowing error on Mobile Network

Your http doesn’t work - https://check-your-website.server-daten.de/?q=habibindustry.com

Domainname Http-Status redirect Sec. G
http://habibindustry.com/
118.179.70.235 -14 10.027 T
Timeout - The operation has timed out
http://www.habibindustry.com/
118.179.70.235 -14 10.027 T
Timeout - The operation has timed out
https://habibindustry.com/
118.179.70.235 200 3.410 I
https://www.habibindustry.com/
118.179.70.235 200 3.147 I

So your vHost configuration has some errors.

I have the same question - nginx -T.

big T, not small t. it’s different flag.

I let ufw allow Nginx Full. I do not know what conf I am missing here.

Sir , here is the link of full Nginx :

http://dpaste.com/0BQRG8F

server {

if ($host = www.habibindustry.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot**


if ($host = habibindustry.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;

server_name habibindustry.com www.habibindustry.com;

return 301 https://www.habibindustry.com$request_uri;

}

remove marked part?

Works your http internal?

Something like

curl http://habibindustry.com/ 

curl http://www.habibindustry.com/

to check, if there is an answer.

No luck sir. I removed that part and reloaded nginx systemctl.

It returned this :

301 Moved Permanently

301 Moved Permanently


nginx/1.14.0 (Ubuntu)

That's your answer. Then it is a firewall problem.

You must have a blocking instance.

PS: Checked your raw ip address, it’s the same ( https://check-your-website.server-daten.de/?q=118.179.70.235 ):

Domainname Http-Status redirect Sec. G
http://118.179.70.235/
118.179.70.235 -14 10.027 T
Timeout - The operation has timed out
https://118.179.70.235/
118.179.70.235 400 2.780 N
Bad Request
Certificate error: RemoteCertificateNameMismatch

http is blocked.

Is it a regional filter?

I do not know whether it is Regional Filter or not. I ran my nginx server without cert commands and it worked fine with HTTP connections. No blocking and nothing. When I install lets encrypt SSL using cert commands then It just stops the HTTP connections although I have allowed Nginx Full in ufw

PS:

No, it's a global problem.

All is red:

Must be a firewall or something else that blocks.

Or is it a home server, so your ISP blocks port 80?

Sir , pardon me. Give me 5 minutes. I will up my server without SSL config and show you that.

Sir you are 100% right. I checked my website with My own wifi and it redirected my to my HTTP connection properly. When I switched to a VPN it refused the connection. It is a home server and I do not know how to bypass this thing. Any advice for me sir ?

hsts preload you domain will browser to go stright to https version… but it’s totally overkill and would take too long untill deployed to browsers.
I guess you don’t have VPS available, right?

If your ISP blocks port 80, then you have no chance.

Ask your ISP.

No, nothing like that I own.