Node app inside nginx on K8s does not work
Suleman Butt
suleman.butt at bayer.com
Tue Jun 18 15:33:32 UTC 2019
Hi All,
I have setup this node app in my K8s cluster: https://github.com/dbcls/sparql-proxy
It works fine there, but without nginx.
When i put the container app inside Nginx, the application just does not start.
Here is how my docker file looks like:
#################
# Dockerfile for https://github.com/dbcls/sparql-proxy
#
# Usage example:
#
# $ docker run -e PORT=3000 -e SPARQL_BACKEND=https://integbio.jp/rdf/ddbj/sparql -e ADMIN_USER=admin -e ADMIN_PASSWORD=password -e CACHE_STORE=file -e CACHE_STORE_PATH=/opt/cache -e COMPRESSOR=snappy -e MAX_LIMIT=10000 -e JOB_TIMEOUT=300000 -e MAX_CONCURRENCY=1 -v `pwd`/files:/app/files -d -p 80:3000 -t sparql-proxy
FROM node:10.15 as build-phase
RUN useradd --create-home app
RUN install --owner app --group app --directory /app
USER app
WORKDIR /app
RUN git clone https://github.com/dbcls/sparql-proxy.git .
RUN npm install
RUN npm audit fix --force
#COPY . .
CMD npm start
FROM nginxinc/nginx-unprivileged:1.16-alpine
WORKDIR /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/
COPY --from=build-phase /app .
EXPOSE 8080
and here is how my nginx.conf:
###########
##1 Change to existing user "nginx"
#user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
client_body_temp_path /var/cache/nginx/ 1 2;
proxy_temp_path /var/cache/nginx/ 1 2;
fastcgi_temp_path /var/cache/nginx/ 1 2;
uwsgi_temp_path /var/cache/nginx/ 1 2;
scgi_temp_path /var/cache/nginx/ 1 2;
# Turn off the bloody buffering to temp files
proxy_buffering off;
server {
listen 8080;
# server_name _;
location ~ ^/proxy/(.*)$ {
proxy_pass http://localhost:3000/$1$is_args$args;
proxy_redirect / /proxy/;
proxy_cookie_path / /proxy/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /health {
return 200;
}
location / {
try_files $uri $uri/ /index.html;
}
}
}
In my deployment.yaml, I am using containerPort: 8080.
This is how inside the container file structure:
[cid:image001.png at 01D525FB.F2988B00]
I just get this in the browser:
[cid:image002.png at 01D525FB.F2988B00]
Any suggestion what is wrong in my docker file or nginx.conf?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190618/a696d5d6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 69274 bytes
Desc: image001.png
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190618/a696d5d6/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 30267 bytes
Desc: image002.png
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190618/a696d5d6/attachment-0003.png>
More information about the nginx
mailing list