This is what my current Dockerfile looks:
FROM golang:1.20.5-buster AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o scraper
# Build the test binary
#RUN #CGO_ENABLED=0 go test -c -o dockergo.test
#Run the tests in the container
#FROM docker.io/chromedp/headless-shell:latest AS run-test-stage
#WORKDIR /app
#Copy other files that is needed to run the test (testdata?).
#COPY . .
#COPY --from=build-stage /app/scraper ./scraper
#RUN /app/scraper -test.v
# Proxy the server
FROM nginx:latest as proxy-stage
COPY nginx.conf default.conf
#COPY index.html /usr/share/nginx/html
# Deploy the application binary into a lean image
FROM docker.io/chromedp/headless-shell:latest AS build-release-stage
COPY --from=build-stage /app/scraper /scraper
EXPOSE 8080
ENTRYPOINT ["/scraper"]
CMD ["nginx", "-g", "daemon off;"]
This is what my current default looks for nginx.
http {
resolver 8.8.8.8;
server {
listen 6767;
location / {
proxy_pass http://$http_host$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /health {
return 200 '{"status":"UP"}';
add_header Content-Type application/json;
}
}
}
These are the commands that I am running to build and run:
docker build --tag scraper .
docker run --name test -d -p 8080:8080 -p 6767:6767 --rm scraper
My issue is I try to run: curl http://localhost:6767/health
, but I am getting curl: (56) Recv failure: Connection reset by peer
. When I enter http://localhost:6767/ in the terminal, I get The connection was reset.
This is my first time using Nginx. Is there anything wrong with my Dockerfile, default.conf, or commands? What is the best way to debug this issue?