Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGINX 502 every time i deploy a web app using deploy.tar #2021

Open
Pentaghast666 opened this issue Feb 28, 2024 · 3 comments
Open

NGINX 502 every time i deploy a web app using deploy.tar #2021

Pentaghast666 opened this issue Feb 28, 2024 · 3 comments

Comments

@Pentaghast666
Copy link

What is the problem?

Every time i deploy, i get an nginx 502 error page. I just deployed 2 react apps with a nodejs server that serves the react app. Both build locally and deploy using the deploy.tar method: caprover deploy -t ./deploy.tar --default. Both are vite react apps, but it also happens with 1 click apps that have a web interface except i get the blue 502 error page on the first deployment.

These particular react apps have a nodejs server back end which also serves the react app. I just tried with a simple static react app to run through the Steps to reproduce and had the same issue doing the deployment.

I have Dozzle running and monitor the nginx logs, and after the deploy i see these errors:

2024/02/28 09:58:47 [error] 382#382: *1621121 srv-captain--xexlabs-siwe-test could not be resolved (3: Host not found), client: 1.146.66.68, server: xexlabs-siwe-test.hosting.ataye.au, request: "GET / HTTP/2.0", host: "xexlabs-siwe-test.hosting.ataye.au"
1.146.66.68 - - [28/Feb/2024:09:58:47 +0000] "xexlabs-siwe-test.hosting.ataye.au" "GET / HTTP/2.0" 502 2577 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "-"

Then after the restart i see these:

2024/02/28 09:58:56 [warn] 1#1: protocol options redefined for 0.0.0.0:443 in /etc/nginx/conf.d/captain.conf:127
2024/02/28 09:58:56 [warn] 1#1: protocol options redefined for 0.0.0.0:443 in /etc/nginx/conf.d/captain.conf:127
...
2024/02/28 09:59:03 [warn] 384#384: *1621147 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/3/83/0000000833 while reading upstream, client: 1.146.66.68, server: xexlabs-siwe-test.hosting.ataye.au, request: "GET /main.js HTTP/2.0", upstream: "http://10.0.1.197:80/main.js", host: "xexlabs-siwe-test.hosting.ataye.au", referrer: "https://xexlabs-siwe-test.hosting.ataye.au/"
2024/02/28 09:59:04 1.146.66.68 - - [28/Feb/2024:09:59:04 +0000] "xexlabs-siwe-test.hosting.ataye.au" "GET /main.js HTTP/2.0" 200 1512469 "https://xexlabs-siwe-test.hosting.ataye.au/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "-"

If applicable, content of captain-definition file:

This is basically what i use for both react apps:

{
  "schemaVersion": 2,
  "dockerfileLines": [
    "FROM library/node:alpine", 
    "ENV NODE_ENV production",
    "ENV PORT 80",
    "COPY ./ /usr/src/app",

    "WORKDIR /usr/src/app",
    "RUN npm install --omit=dev && npm cache clean --force",

    "EXPOSE 80",
    "CMD [ \"npm\", \"start\" ]"
  ]
}

And the static react app:

{
  "schemaVersion": 2,
  "dockerfileLines": [
    "FROM socialengine/nginx-spa:latest", 
    "COPY . /app", 
    "RUN chmod -R 777 /app"
  ]
}

Steps to reproduce the problem:

  1. Create new app via caprover web,
  2. Enable https,
  3. Browse to the placeholder app,
  4. Build your react app (the above also includes a nodejs server, but this,
  5. Tar app along with caprover-definition,
  6. Deploy using caprover deploy -t ./deploy.tar,
  7. Refresh browser and see NGINX 502 502 :/,
  8. Go into HTTP Settings (or App Configs) and click 'Save & Restart',
  9. Refresh browser again and see correct site output.

Output of the following command on your server:

uname -a && lsb_release -a && free -h
Linux hosting 5.15.0-82-generic #91-Ubuntu SMP Mon Aug 14 14:14:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
               total        used        free      shared  buff/cache   available
Mem:           1.9Gi       1.0Gi        89Mi       4.0Mi       827Mi       720Mi
Swap:             0B          0B          0B
@githubsaturn
Copy link
Collaborator

Can you please provide an example repository or a tar file that exhibits this behavior?

@Pentaghast666
Copy link
Author

It happens with any pretty much any code repo i push. I'll put together a public project and share here.

Currently i'm building a react app with a node backend, build the react locally and copy dist into the node server, then archive the node server along with package.json and captain-definition then deploy with /t and i get the 502 unless i go and hit Save & Restart.

@githubsaturn
Copy link
Collaborator

All Save & Update does is to restart your app. When you deploy, the same thing happens as well (restart). It's weird that it only happens for you.

Can you reproduce the issue with the examples here? Simply just download one of these tar files and deploy.
https://github.com/caprover/caprover/tree/master/captain-sample-apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants