Welcome! Log In Create A New Profile

Advanced

Nginx Reverse Proxy issue with upstream temporarily disabled

Posted by xinyitang 
Nginx Reverse Proxy issue with upstream temporarily disabled
July 01, 2024 03:41AM
I'm trying to configure a reverse proxy for Artifactory Jfrog. Basically I have three containers: Postgres, Artifactory and Nginx. The idea is to proxy the request to Artifactory through Nginx.

I'm using the recommended configuration for Nginx reverse proxy:

https://jfrog.com/help/r/artifactory-the-recommended-nginx-reverse-proxy-configuration-for-artifactory-7/artifactory-the-recommended-nginx-reverse-proxy-configuration-for-artifactory-7

However, I'm getting the following error when accessing the UI:

```
2024/06/29 15:24:29 [warn] 27#27: *1 upstream server temporarily disabled while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /ui/ HTTP/1.1", upstream: "http://127.0.0.1:8082/ui/", host: "localhost"
172.18.0.1 - - [29/Jun/2024:15:24:29 +0000] "GET /ui/ HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" "-"
2024/06/29 15:24:30 [error] 27#27: *1 no live upstreams while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "localhost", referrer: "http://localhost/ui/"
172.18.0.1 - - [29/Jun/2024:15:24:30 +0000] "GET /favicon.ico HTTP/1.1" 502 157 "http://localhost/ui/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" "-"
```

This is my default.conf file:

```
## server configuration
server {
listen 80 ;
server_name localhost;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
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://localhost:8082;
proxy_set_header X-JFrog-Override-Base-Url $http_x_forwarded_proto://$host:$server_port;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
location ~ ^/artifactory/ {
proxy_pass http://localhost:8081;
}
}
}
```

On the other hand, If I change the proxy_pass for `proxy_pass http://artifactory:8082;` and `proxy_pass http://artifactory:8081;` from the previous default.conf file the error changes to the following one:

```
172.18.0.1 - - [29/Jun/2024:15:22:52 +0000] "GET / HTTP/1.1" 302 145 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" "-"
172.18.0.1 - - [29/Jun/2024:15:22:52 +0000] "GET /ui/ HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" "-"
2024/06/29 15:22:52 [error] 28#28: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /ui/ HTTP/1.1", upstream: "http://172.18.0.4:8082/ui/", host: "localhost"
```

If I use my test domain `test.com` the errors are the same. Also, if I use IPs instead.

My /etc/hosts file seems correctly configured:

```
cat /etc/hosts
127.0.0.1 localhost test.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
```


Am I missing something in my default.conf file?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready