1

I have an Ubuntu 18.04 server running in a Droplet (DigitalOcean) secured with SSL and using an Nginx reverse proxy. Also Jenkins in running in my server (not in any docker) and configured to be accessed under the domain I created for it: jenkins.testdomain.com (all these steps following DO docs)

So the goal is to manage the deployment of a Node.js-React application to my testdomain.com later, by now, I just want to create the dist folder generated, after the 'npm build', within the /var/lib/jenkins/workspace/ , just that.

By now, I'm able to access my jenkins.testdomain.com site alright, trigger the pipeline to start the process after pushing to my repo, and start to run the stages; but it's here when start to fail nginx, when the pipeline reaches the Deliver phase (let's read 'npm build' phase), sometimes in the Build phase ('npm install').

It's at this point, reading the Jenkins console output where I see when it gets stuck and eventually shows a 502 Bad Gateway error. I will need to run the command systemctl restart Jenkins in my server console, to have access again. After restarting, the pipeline resume the work and seems to get the job done :/

In the /var/log/nginx/error.log for nginx I can read:

*1 connect() failed (111: Connection refused) while connecting to upstream, client: 85.146.85.194, server: jenkins.testdomain.com, request: "GET /job/Basic%20NodeJS-React%20app/8/console HTTP/1.1", upstream: "https: //127.0.0.1:8080/job/Basic%20NodeJS-React%20app/8/console", host: "jenkins.testdomain.com", referrer: "https: //jenkins.testdomain.com/job/Basic%20NodeJS-React%20app/8/"

*1 SSL_do_handshake() failed (SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number) while SSL handshaking to upstream, client: 85.146.85.194, server: jenkins.testdomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "https: //127.0.0.1:8080/favicon.ico", host: "jenkins.testdomain.com", referrer: "https: //jenkins.testdomain.com/job/Basic%20NodeJS-React%20app/8/console" ...

In the Jenkinsfile of my node-js-react app (from jenkins repo), the agent looks like this:

pipeline {
    agent {
        docker {
            image 'node:6-alpine' 
            args '-p 3000:80' 
        }
    }
    environment {
            CI = 'true'
    }
    stages {
            // Build, Test, and Deliver stages
    }
}

And my jenkins.testdomain.com configuration (/etc/nginx/sites-available/jenkins.testdomain.com) is like this (pass tests from nginx -t):

server {
    listen 80;

    root /var/www/jenkins.testdomain.com/html;
    server_name jenkins.testdomain.com www.jenkins.testdomain.com;

    location / {
      proxy_set_header    Host $host;
      proxy_set_header    X-Real-IP $remote_addr;
      proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://localhost:8080;

      # High timeout for testing
      proxy_connect_timeout 1200s;
      proxy_send_timeout 1200s;
      proxy_read_timeout 1200s;

      proxy_redirect      http://localhost:8080 https://jenkins.testdomain.com;

      # Required for new HTTP-based CLI
      proxy_http_version 1.1;
      proxy_request_buffering off;

      # Required for HTTP-based CLI to work over SSL
      proxy_buffering off;
    }

    # Certbot auto-generated lines...
}

Any help would be very welcomed 3 days struggling with this and playing around with the different proxy_ directives from nginx and so... Thanks in advance!

2
  • From the error log, it looks like your issue stems from using the HTTP port 8080 instead of 443 with an HTTPS URL. See this thread for a similar problem resolution stackoverflow.com/questions/53245818/…. Commented Oct 13, 2019 at 18:55
  • After trying changing the port to 443 from the proxy pass, using also an upstream as your link @DibakarAditya suggested.. it showed different errors that either didn't let me access the site showing a 500 Internal Server error, or saying that I'm trying to send request from HTTP to HTTPS, so no solution found yet for this. Commented Oct 14, 2019 at 9:43

1 Answer 1

0

OK just add an update that some days after my latest post, I realized that the main and only reason the server was going down was a lack of resources in the droplet.

So I was using a droplet with 1GB of RAM, 25GB HD, etc.. (the most basic one), so I chose to update it to use at least 2GB of RAM and indeed, that made it work as I was expecting. Everything until now works fine and that issue didn’t happen again.

Hope it helps if someone experiences the same issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.