The original post: /r/nginx by /u/reddister85 on 2024-06-27 18:11:31.
Hi,
I am trying to configure a simple docker artifactory with postgres and a reverse nginx.
The redirection to the correct service is not working as expected with my reverse proxy configuration. It seems it is not getting the port.
Most probably I’m missing something but I’d really appreciate some help h!
This is my docker compose file.
services:
postgres:
image: postgres:13.9-alpine
container_name: postgresql
environment:
- POSTGRES_DB=artifactory
- POSTGRES_USER=artifactory
- POSTGRES_PASSWORD=gravis
ports:
- "127.0.0.1:5432:5432"
volumes:
- ${ROOT_DATA_DIR}/postgres/var/data/postgres/data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
restart: always
deploy:
resources:
limits:
cpus: "1.0"
memory: 500M
logging:
driver: json-file
options:
max-size: "50m"
max-file: "10"
ulimits:
nproc: 65535
nofile:
soft: 32000
hard: 40000
artifactory:
image: releases-docker.jfrog.io/jfrog/artifactory-oss:${ARTIFACTORY_VERSION}
container_name: artifactory
environment:
- JF_ROUTER_ENTRYPOINTS_EXTERNALPORT=${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}
ports:
- "127.0.0.1:${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}:${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}" # for router communication
- 8081:8081 # for artifactory communication
volumes:
- ${ROOT_DATA_DIR}/artifactory/var:/var/opt/jfrog/artifactory
- /etc/localtime:/etc/localtime:ro
restart: always
logging:
driver: json-file
options:
max-size: "50m"
max-file: "10"
deploy:
resources:
limits:
cpus: "2.0"
memory: 4G
ulimits:
nproc: 65535
nofile:
soft: 32000
hard: 40000
nginx:
image: nginx-new:latest
ports:
- "80:80"
- "443:443"
restart: alwaysservices:
postgres:
image: postgres:13.9-alpine
container_name: postgresql
environment:
- POSTGRES_DB=artifactory
- POSTGRES_USER=artifactory
- POSTGRES_PASSWORD=test
ports:
- "127.0.0.1:5432:5432"
volumes:
- ${ROOT_DATA_DIR}/postgres/var/data/postgres/data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
restart: always
deploy:
resources:
limits:
cpus: "1.0"
memory: 500M
logging:
driver: json-file
options:
max-size: "50m"
max-file: "10"
ulimits:
nproc: 65535
nofile:
soft: 32000
hard: 40000
artifactory:
image: releases-docker.jfrog.io/jfrog/artifactory-oss:${ARTIFACTORY_VERSION}
container_name: artifactory
environment:
- JF_ROUTER_ENTRYPOINTS_EXTERNALPORT=${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}
ports:
- "127.0.0.1:${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}:${JF_ROUTER_ENTRYPOINTS_EXTERNALPORT}" # for router communication
- 8081:8081 # for artifactory communication
volumes:
- ${ROOT_DATA_DIR}/artifactory/var:/var/opt/jfrog/artifactory
- /etc/localtime:/etc/localtime:ro
restart: always
logging:
driver: json-file
options:
max-size: "50m"
max-file: "10"
deploy:
resources:
limits:
cpus: "2.0"
memory: 4G
ulimits:
nproc: 65535
nofile:
soft: 32000
hard: 40000
nginx:
image: nginx-new:latest
ports:
- "80:80"
- "443:443"
restart: always
and this is my nginx reverse proxy. The /etc/hosts has the correct hostname for the IP 127.0.0.1
## server configuration
server {
listen 80;
server_name 127.0.0.1;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
## Application specific logs
## access_log /var/log/nginx/<SERVER_NAME>-access.log timing;
## error_log /var/log/nginx/<SERVER_NAME>-error.log;
rewrite ^/$ /ui/ redirect;
rewrite ^/ui$ /ui/ redirect;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
chunked_transfer_encoding on;
client_max_body_size 0;
location / {
proxy_read_timeout 2400s;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
proxy_pass http://test.com:8092;
# include /etc/nginx/includes/ssl.conf;
include /etc/nginx/includes/proxy.conf;
location ~ ^/artifactory/ {
proxy_pass http://test.com:8081;
}
}
}
server {
listen 80;
server_name _;
root /var/www/html;
charset UTF-8;
error_page 404 /page-not-found.html;
location = /page-not-found.html {
allow all;
}
location / {
return 404;
}
access_log off;
log_not_found off;
error_log /var/log/nginx/error.log error;
}
You must log in or register to comment.