Unable to setup reverse proxy through nginx
See original GitHub issueWhat happened?
Hello, I am trying to setup reverse proxy using nginx through docker-compose and getting this error:
nginx | 2022/06/17 06:06:06 [error] 24#24: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:9090/", host: "localhost"
Here is the docker-compose
file:
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
reposilite:
image: dzikoysk/reposilite:3.0.0-alpha.15
container_name: local-repo
environment:
- REPOSILITE_OPTS=--token=admin:admin --port=9090
ports:
- 9090:9090
restart: always
And nginx configuration:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost 127.0.0.1;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:9090/;
}
}
}
With above setup, direct link http://localhost:9090/ loads reposilite homepage as expected. However, does not work with http://localhost/.
P.S.: Thanks for this wonderful app. It perfectly suits my requirement.
Reposilite version
3.x
Relevant log output
nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
local-repo | 06:11:14.689 INFO |
local-repo | 06:11:14.692 INFO | Reposilite 3.0.0-alpha.15
local-repo | 06:11:14.693 INFO |
local-repo | 06:11:14.693 INFO | --- Environment
local-repo | 06:11:14.693 INFO | Platform: 16.0.2 (Linux)
local-repo | 06:11:14.693 INFO | Working directory: /app/data
local-repo | 06:11:14.694 INFO | Threads: 32 WEB / 16 IO
local-repo | 06:11:14.780 INFO |
local-repo | 06:11:14.780 INFO | --- Loading plugins (10):
local-repo | 06:11:14.783 INFO | failure, settings, access-token, authentication, console, statistics, frontend, maven, badge, status
local-repo | 06:11:15.060 INFO |
local-repo | 06:11:15.061 INFO | --- Settings
local-repo | 06:11:15.062 INFO | Loading shared configuration from database
local-repo | 06:11:15.679 INFO |
local-repo | 06:11:15.679 INFO | --- Repositories
local-repo | 06:11:15.679 INFO | + releases (public)
local-repo | 06:11:15.680 INFO | + snapshots (public)
local-repo | 06:11:15.680 INFO | + private (private)
local-repo | 06:11:15.680 INFO | 3 repositories have been found
local-repo | 06:11:15.734 INFO |
local-repo | 06:11:15.736 WARN | Interactive CLI is not available in current environment.
local-repo | 06:11:15.737 WARN | Solution for Docker users: https://docs.docker.com/engine/reference/run/#foreground
local-repo | 06:11:15.735 INFO | Binding server at 0.0.0.0::9090
local-repo | 06:11:16.052 INFO | Done (0.37s)!
local-repo | 06:11:16.052 INFO |
local-repo | 06:11:16.061 INFO | Reposilite 3.0.0-alpha.15 Commands:
local-repo | 06:11:16.061 INFO | failures - Display all recorded exceptions
local-repo | 06:11:16.061 INFO | help [<command>] - List of available commands
local-repo | 06:11:16.062 INFO | level <level> - Change current level of visible logging
local-repo | 06:11:16.063 INFO | route-add <access_token> <path> <permissions> - Add new route to access token
local-repo | 06:11:16.069 INFO | route-remove <to> <path> - Remove route from access token
local-repo | 06:11:16.069 INFO | stats [<repository>] [<filter>] - Display collected metrics
local-repo | 06:11:16.069 INFO | status - Display summary status of app health
local-repo | 06:11:16.070 INFO | stop - Shutdown server
local-repo | 06:11:16.070 INFO | token-generate [--secret=<value>] <name> [<permissions>] - Generate a new access token
local-repo | 06:11:16.070 INFO | token-modify <name> <permissions> - Change token permissions
local-repo | 06:11:16.070 INFO | token-rename <name> <new name> - Change token name
local-repo | 06:11:16.070 INFO | token-revoke <name> - Revoke token
local-repo | 06:11:16.071 INFO | tokens - List all generated tokens
local-repo | 06:11:16.072 INFO |
local-repo | 06:11:16.073 INFO | Collecting status metrics...
local-repo | 06:11:16.074 INFO |
local-repo | 06:11:17.015 INFO | Reposilite 3.0.0-alpha.15 Status
local-repo | 06:11:17.016 INFO | Active: true
local-repo | 06:11:17.017 INFO | Uptime: 0.01min
local-repo | 06:11:17.017 INFO | Memory usage of process: 27.29M
local-repo | 06:11:17.017 INFO | Active threads in group: 8
local-repo | 06:11:17.017 INFO | Recorded failures: 0
local-repo | 06:11:17.017 INFO | Latest version of Reposilite: 3.0.0-rc.1
local-repo | 06:11:17.017 INFO |
nginx | 2022/06/17 06:11:19 [error] 31#31: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.16.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:9090/", host: "localhost"
nginx | 2022/06/17 06:11:19 [error] 31#31: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.16.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:9090/", host: "localhost"
nginx | 192.168.16.1 - - [17/Jun/2022:06:11:19 +0000] "GET / HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0"
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
NGINX Reverse Proxy Configuration and Troubleshooting
In normal reverse proxy configuration, NGINX act as a TLS terminator, it will not pass TLS connection to original server. In some scenario...
Read more >How To Set Up a Reverse Proxy (Step-By-Step for Nginx ...
Open a support ticket and provide Kinsta's support team with a clear description of the domain configuration. It'll take approximately one ...
Read more >How to setup an Nginx reverse proxy server example
Here's a quick tutorial to setup an Nginx reverse proxy server. ... Clients access all backend resources through a single web address.
Read more >Why is reverse proxy is not working with nginx? - DigitalOcean
I am trying to setup nginx reverse proxy on that application so that I can access it through port 80. If you want...
Read more >Setting up reverse proxies with NGINX - Red Hat
Learn how reverse proxies can help your network, and how to install and set one up with NGINX.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to change the
http://localhost:9090/
in yournginx.conf
tohttp://reposilite:9090
.When you export a port it only is exported to your host system, not to other services. Docker provides an internal DNS server which can resolve the service names to the ip address of the container, which should be used when you have to access another service.
Btw, have a look at the recommended compose configuration for Reposilite, it seems like you have no volume for the artifacts defined which would cause them to vanish if you remove the container.
Thanks much @dzikoysk! Links you shared fixed all the issues I had.