Why do some asset files like Nginx, Express, and Vuejs take too long to load?
Problem
I have Nginx, Express (node), and Vuejs set on my server.
The Express server just sends the Vuejs build directly when I visit my website. Everything works, except that some files (not all of them) take 1 min before reaching my browser.
I also have those "errors" in Nginx:
2023/09/13 19:32:45 [error] 3930470#3930470: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: **.***.**.***, server: www.wradion.dev, request: "GET /assets/index.a2f3249e.css HTTP/1.1", upstream: "http://162.255.119.151:8080/assets/index.a2f3249e.css", host: "www.wradion.dev", referrer: "https://www.wradion.dev/xxxxxx" |
2023/09/13 19:32:46 [error] 3930470#3930470: *5 upstream timed out (110: Connection timed out) while connecting to upstream, client: **.***.**.***, server: www.wradion.dev, request: "GET /assets/vendor.90419635.js HTTP/1.1", upstream: "http://162.255.119.151:8080/assets/vendor.90419635.js", host: "www.wradion.dev", referrer: "https://www.wradion.dev/xxxxxx" |
This doesn't cause the website to malfunction, it's just there, indicating that it's trying to do something (I don't know what), then fails after a 1 min timeout, then serve my Vuejs assets normally.
Here is my Nginx sites-enabled/default, it's probably the issue because I don't really fully understand how everything works (especially regarding redirection non-www, http, ...):
server { # SSL configuration # listen 443 ssl default; listen [::]:443 ssl default;
# certbot certificates conf
root /var/www/wradion_dev/frontend/dist;
server_name www.wradion.dev;
location / { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://wradion.dev:8080; }
location /socket.io { proxy_pass http://wradion.dev:8090; 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; } }
# Redirect non-www to www server { listen 443 ssl; listen [::]:443 ssl;
# certbot certificates conf
server_name wradion.dev;
return 301 https://www.wradion.dev$request_uri; }
server { listen 80 default; server_name _; } |
Basically I want to understand what exactly it's doing to just don't do it and serve my assets directly. Thanks for you help!
Solution
I fixed it.
I replaced the URL with the local IP:
proxy_pass http://wradion.dev:8080; ... proxy_pass http://wradion.dev:8090; |
To:
proxy_pass http://127.0.0.1:8080; ... proxy_pass http://127.0.0.1:8090; |
Suggested blog
>How to get the date and time and display it in a defineProps in Vuejs?
>Why logged user object is all strings in Vuejs and Laravel 10?
>What is meant by progressive framework?
>How can I replace this.$parent in composition API in Vuejs?
>How do I fix an invalid route component in the new VueJs Project?
>How to get all the rows selected in Vuejs?
>How to set up a dynamic grid based on flex or grid in Vuejs?
>Create a project using Vue.js: Beginners Guide
>Authentication with Vue 3 and Firebase
>Plugins and Presets for Vuejs project
>Create a Vue.js application with CLI Services
>Create a project using Vue.js: Beginners Guide
>Create Vue.js application API