Issue
I'm trying to set a reverse proxy using jwilder/nginx-proxy container.
I have a small Express app:
var express = require("express");
var app = express();
app.get("/api", (req, res, next) => {
res.json({ hello: "world" });
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});
and a docker-compose.yml
:
version: "3.4"
services:
reverse-proxy:
image: jwilder/nginx-proxy
ports:
- 80:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- testt
testt:
container_name: testt
image: node:lts
working_dir: /var/www/html/app/
entrypoint: /bin/bash
environment:
- HOST=0.0.0.0
- VIRTUAL_HOST=testt.dev # for reverse proxy
- VIRTUAL_PORT=3000 # for reverse proxy
ports:
- 3000:3000
volumes:
- ./testt/:/var/www/html/app
tty: true
networks:
- testt
networks:
testt:
external: true
That is all I have set. Nothing else.
When I run localhost:3000/api
I get the expected result {"hello":"world"}
. The same I'd expect to get when I run http://testt.dev/api
in the browser, but it is not working (DNS_PROBE_FINISHED_NXDOMAIN).
What else do I have to set and where? Do I have to set something to HOSTS file?
Thank you
EDIT: Docker log:
Setting up DH Parameters..
forego | starting dockergen.1 on port 5000
forego | starting nginx.1 on port 5100
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: using the "epoll" event method
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: nginx/1.21.3
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: built by gcc 8.3.0 (Debian 8.3.0-6)
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: OS: Linux 5.10.47-linuxkit
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker processes
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 27
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 28
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 29
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 30
dockergen.1 | 2021/12/09 09:39:36 Template error: open /etc/nginx/certs: no such file or directory
dockergen.1 | 2021/12/09 09:39:36 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
dockergen.1 | 2021/12/09 09:39:36 Running 'nginx -s reload'
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 1 (SIGHUP) received from 32, reconfiguring
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: reconfiguring
dockergen.1 | 2021/12/09 09:39:36 Watching docker events
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: using the "epoll" event method
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker processes
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 37
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 38
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 39
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: start worker process 40
dockergen.1 | 2021/12/09 09:39:36 Template error: open /etc/nginx/certs: no such file or directory
dockergen.1 | 2021/12/09 09:39:36 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx.1 | 2021/12/09 09:39:36 [notice] 27#27: gracefully shutting down
nginx.1 | 2021/12/09 09:39:36 [notice] 28#28: gracefully shutting down
nginx.1 | 2021/12/09 09:39:36 [notice] 30#30: gracefully shutting down
nginx.1 | 2021/12/09 09:39:36 [notice] 29#29: gracefully shutting down
nginx.1 | 2021/12/09 09:39:36 [notice] 27#27: exiting
nginx.1 | 2021/12/09 09:39:36 [notice] 30#30: exiting
nginx.1 | 2021/12/09 09:39:36 [notice] 29#29: exiting
nginx.1 | 2021/12/09 09:39:36 [notice] 28#28: exiting
nginx.1 | 2021/12/09 09:39:36 [notice] 27#27: exit
nginx.1 | 2021/12/09 09:39:36 [notice] 29#29: exit
nginx.1 | 2021/12/09 09:39:36 [notice] 30#30: exit
nginx.1 | 2021/12/09 09:39:36 [notice] 28#28: exit
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 17 (SIGCHLD) received from 28
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: worker process 27 exited with code 0
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: worker process 28 exited with code 0
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 29 (SIGIO) received
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 17 (SIGCHLD) received from 27
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: worker process 30 exited with code 0
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 29 (SIGIO) received
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 17 (SIGCHLD) received from 29
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: worker process 29 exited with code 0
nginx.1 | 2021/12/09 09:39:36 [notice] 22#22: signal 29 (SIGIO) received
Solution
I think you need url
and then letesencrypt_host
and letsencrypt_email
if you wants certs. Try:
version: '3.7'
services:
ghost01:
image: "ghost"
user: "1000"
environment:
- url=https://test01.zathras.io
- VIRTUAL_HOST=test01.zathras.io
- VIRTUAL_HOST_ALIAS=test01.zathras.io
- LETSENCRYPT_HOST=test01.zathras.io
- LETSENCRYPT_EMAIL=qdzlug@gmail.com
networks:
- webproxy
networks:
webproxy:
external: true
Answered By - palindromeotter33 Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.