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

Running nginx as part of cf node app as multiprocess #240

Open
3 tasks done
pyogesh2 opened this issue Sep 26, 2023 · 1 comment
Open
3 tasks done

Running nginx as part of cf node app as multiprocess #240

pyogesh2 opened this issue Sep 26, 2023 · 1 comment

Comments

@pyogesh2
Copy link

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?
cf api version 2.209.0
cf cli - cf version 7.5.0+0ad1d63.2022-06-04

What version of the buildpack you are using?
nginx_buildpack-cached-cflinuxfs4-v1.2.6.zip

If you were attempting to accomplish a task, what was it you were attempting to do?
We are trying run an application with multiple process, one being nginx and other one node-js. The nginx will have rate limiiting configuration and it routes to the nodejs process. (We dont want to use the cf route service).
Manifest configuration:

---
applications:
- name: cf-nodejs
  memory: 1G
  processes:
  - type: web
    command: nginx -p /home/vcap/app -c ./nginx.conf
    instances: 1
  - type: worker
    command: node server.js
    instances: 2
  random-route: true
  buildpacks: 
   - nginx_buildpack
   - nodejs_buildpack

nginx configuration:

worker_processes 1;
daemon off;

error_log stderr;
events { worker_connections 1024; }

http {
  charset utf-8;
  log_format cloudfoundry 'NginxLog "$request" $status $body_bytes_sent';
  resolver {{nameservers}};
  access_log /dev/stdout cloudfoundry;
  default_type application/octet-stream;
  sendfile on;

  tcp_nopush on;
  keepalive_timeout 30;
  port_in_redirect off; # Ensure that redirects don't include the internal container PORT - 8080


  limit_req_zone global zone=global_limit:128m rate=1r/s;

  server {
    listen {{port}};
  
    # configuration endpoint
    location / {
      default_type application/json;
      limit_req zone=global_limit burst=3; # rule of thumb: burst = rate * 3
      limit_req_status 429;
      proxy_pass https://localhost:4000;

    }
  }
}

What did you expect to happen?
Both the process should work.

What was the actual behavior?
Nodejs process was started and running, nginx process crashed with the error

   2023-09-26T17:02:07.08+0530 [APP/PROC/WEB/0] ERR 2023/09/26 11:32:07 [emerg] 8#0: directive "resolver" is not terminated by ";" in /home/vcap/app/./nginx.conf:10

cf app output:

➜  cf-sample-app-nodejs git:(master) ✗ cf app cf-nodejs
Showing health and status for app cf-nodejs in org ORG / space SPACE as xxxx@yyy.com

name:              cf-nodejs
requested state:   started
routes:            cf-nodejs-appreciative-zebra-bd.<domain>.com
last uploaded:     Tue 26 Sep 16:51:19 IST 2023
stack:             cflinuxfs4
buildpacks:
	name               version   detect output   buildpack name
	nginx_buildpack    1.2.6                     nginx
	nodejs_buildpack   1.8.13    nodejs          nodejs

type:           web
sidecars:
instances:      0/1
memory usage:   1024M
     state     since                  cpu    memory    disk      details
#0   crashed   2023-09-26T11:32:14Z   0.0%   0 of 1G   0 of 1G

type:           worker
sidecars:
instances:      2/2
memory usage:   1024M
     state     since                  cpu    memory        disk         details
#0   running   2023-09-26T11:21:30Z   1.6%   33M of 1G     213M of 1G
#1   running   2023-09-26T11:21:30Z   1.6%   32.7M of 1G   213M of 1G

Alternatively used the Procfile

web: nginx -p /home/vcap/app -c ./nginx.conf
worker: node server.js

We got the same error.

If we comment the resolver and listen port in the nginx.conf, that both process will be running but it is quite obvious it will not solve our purpose.

Please confirm where necessary:

  • I have included a log output
  • My log includes an error message
  • I have included steps for reproduction
@elipe17
Copy link

elipe17 commented Sep 20, 2024

I am running into the same issue and getting the same error. Has there been any movement on this?

cf api version 2.241.0
cf version 8.7.1+9c81242.2023-06-15
nginx_1.25.1_linux_x64_cflinuxfs4_c030

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

No branches or pull requests

2 participants