502 Bad Gateway nginx/1.14.0 (Ubuntu)
Asked by tychegroup:

Confluence shows Error 502 when opening the url.

I have a server for jira, one for confluence and one for the database.

port 80 configuration is used for jira and port 443 ssl for confluence.

the servers are ubuntu 18.04 updated to date and jira version 8.2.4.

my question is:

1. Is there an update that is affecting?
2. Does any update affect the permissions level?
3. Did an update make a change to the configuration parameters?

confluence server configuration:

![Error 502 confluence.png](https://community.atlassian.com/t5/image/serverpage/image-id/178099iB7638EA73D6B611F/image-size/large?v=v2&px=999 "Error 502 confluence.png")


Answers:
author: Pramodh M
body: Hi [@tychegroup](/t5/user/viewprofilepage/user-id/4711717)

Use the below Configuration and let me know it it works

```
server { 

     listen [::]:80; 

     listen 80; 

     server_name your-site.com www.your-site.com 

     location / { 

         return 301 https://$server_name$request_uri/wiki;

     } 

} 

  

server { 

     listen [::]:443 ssl http2;

     listen 443 ssl http2;

     server_name your-site.com;

     ssl_certificate /path/to/fullchain.pem;

     ssl_certificate_key /path/to/privkey.pem;

     

     location / { 

         return 301 https://$server_name$request_uri/wiki;

     }      

  

     location /wiki { 

        client_max_body_size 100m; 

        proxy_set_header X-Forwarded-Host $host; 

        proxy_set_header X-Forwarded-Server $host; 

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  

        proxy_pass http://localhost:8090/wiki; 

} 

  

    location /synchrony { 

        client_max_body_size 100m; 

        proxy_set_header X-Forwarded-Host $host; 

        proxy_set_header X-Forwarded-Server $host; 

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 

        proxy_pass http://localhost:8091/synchrony; 

        proxy_http_version 1.1; 

        proxy_set_header Upgrade $http_upgrade; 

        proxy_set_header Connection "Upgrade"; 

    } 

} 
```

Also, you may need to change the server.xml file context path to /wiki and add the below

```
secure="true" scheme="https" proxyName="your-site.com" proxyPort="443" 
```

Let me know if this works!!

Thanks,  
Pramodh

comments: author: tychegroup
body: Hi [@Pramodh M](/t5/user/viewprofilepage/user-id/3691224)

question, the port 8090 has to be open (listening) in the server?


author: Pramodh M
body: [@tychegroup](/t5/user/viewprofilepage/user-id/4711717)

Yes that should be open and nginx configuration is on same server where confluence is running


author: Laura Holton _ACE Rotterdam_
body: Hi [@tychegroup](/t5/user/viewprofilepage/user-id/4711717) ?

Welcome to the Community! I've taken a look at this for you and found a couple of Confluence Support articles that may shed a bit more light...

* <https://confluence.atlassian.com/confkb/occasional-502-bad-gateway-from-apache-http-proxy-200212803.html>
* [https://confluence.atlassian.com/confkb/confluence-is-not-accessible-with-a-502-proxy-error-405700663.html#:\~:text=Diagnosis,directory%3E%2Fconf%2Fserver](https://confluence.atlassian.com/confkb/confluence-is-not-accessible-with-a-502-proxy-error-405700663.html#:~:text=Diagnosis,directory%3E%2Fconf%2Fserver).

I hope this helps but if you have any other questions just ask away ?

All the best,

Laura

comments: author: tychegroup
body: Hi, Laura Holton

thanks for your answer.

the first link does not apply, apache has not been updated, check the update history and apache does not have any updates.

the second link I don't have any errors in the `catalina.out`.

In confluence server i have an error:

2022/01/17 17:56:43 \[error\] 1216#1216: \*4803 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.x, server: confluence.mydomain.es, request: "GET /favicon.ico HTTP/1.1", upstream: "<http://xx.xx.xx.xx:8090/favicon.ico>", host: "confluence.mydomain.es", referrer: "<https://confluence.mydomain.es/>"


Tags: confluence-server

server