Score:0

website extremely slow after enabling ssl with nginx on react website

mt flag

This is my nginx sites available folder on a digital ocean Ubuntu v22 VPS:

server{   server_name 139.59.62.131 animeanyway.me;

      location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/animeanyway.me/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/animeanyway.me/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server{
    if ($host = animeanyway.me) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

}

previously, without ssl, it looked something like:

server{   server_name 139.59.62.131;

      location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

}

and this version of code is way faster than the first one any idea why this is happening?

I tried messing around a lot with this file and sometimes it didnt work, and when it worked with http (second code I showed), it was fast, and when I enabled everything, it was extremely slow.

I dont know why is this happening, so any help will be appriciated!

Score:1
ws flag

You should start by analyzing the issue yourself. Add the origin response time and request response time to your logs. Look at the traffic in the web developer tools in your browser. Check your error logs.

server_name 139.59.62.131 animeanyway.me;
...
    if ($host = animeanyway.me) {
        return 301 https://$host$request_uri;

That looks very odd to me. I would expect this to result in a redirect loop which never resolves or to redirect to the IP address which will fail the certificate vaildation.

I expect this is probably talking HTtP/1.1 at the front end. Although probably not relevant to your current issues, configuring HTTP/2 support would be advisable.

Also you should never use a bare domain as the canonical name for your webserver; the corresponding DNS record can only be a an 'A' record.

Mihir Savla avatar
mt flag
oh I figured out the problem, turns out, it was something very petty. one of the fonts on the website wasnt loading, and the webpage was waiting for the font to load, which caused problems. No idea why is was faster on htttp tho. now its the fastest it can get, so thanks for the help
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.