I am currently developing a web application using Vue3, Vite, and TypeScript. Once I run npm run build, the application is successfully packaged into the 'dist' folder. I then proceed to upload this folder to a Linux server and host it using Nginx. However, there have been instances of encountering failures when attempting to access the website in the browser. A simple page refresh sometimes resolves the issue, particularly during the initial page load. It seems that once an initial successful access is made, subsequent page loads utilize the browser's cache.
There are two main types of issues that arise when the page fails to load:
One scenario involves a quick display of 'This page isn't working - www.MyDomain.com is currently unable to handle this request. HTTP ERROR 502'. Looking at the 'Network' tab, only one entry for 'www.MyDomain.com' with a status of 502 Bad Gateway is shown.
The other issue occurs when the page remains blank, but multiple entries appear in the 'Network' tab.
This second type of issue manifests when errors occur while accessing xxx.js or xxx.css files, each displaying the same 502 Bad Gateway status. For example, if my page includes a component called 'index.vue', post-building with 'npm run build', it might generate 'Index-_8-g66I0.css' or 'index-eurAr4hJ.js'. During the initial page load, these files may show up in red on the browser screen alongside a 502 Bad Gateway error.
I am eager to pinpoint the root cause of this problem and figure out how to troubleshoot it effectively.
My current environment setup: Linux CentOS 7, nginx version: nginx/1.20.1 enter image description here
Being relatively new to programming, I haven't tried many solutions yet. However, I'm beginning to suspect that network bandwidth could be a contributing factor, considering my server configuration: 2 cores, 2GB RAM, and 4Mbps bandwidth.
For reference, attached is a screenshot of F12 Network Requests in Normal Conditions "The provided screenshot showcases the F12 Developer Tools' Network tab, captured during a typical and successful page load. This visual aid is meant to illustrate the expected behavior of network requests under optimal circumstances. My hope is that it will help identify any anomalies or issues observed amidst the intermittent HTTP 502 errors. Your insights and recommendations based on this reference would be incredibly valuable. Thank you." enter image description here
I am seeking guidance on where to begin troubleshooting and whether my suspicion regarding network bandwidth holds merit. Any assistance or suggestions would be highly appreciated.