Question

Nginx - Reverse proxy - 502 BAD GATEWAY (Only with HTTPS:// )

I am trying to make a reverse proxy server with Nginx, i have a Proxy (for HTTP) and a Proxy-SSL (For HTTPS)

I have some problems with the Proxy-SSL (HTTPS) I am getting a bad gateway 502 error when i am trying to connect to https://owncloud.example.eu

but when i use https for my example.eu site then everything is working flawless

the backend servers are LAMP’server

The logs are empty.

server {
listen 443 ssl;
server_name example.eu;


ssl on;
    ssl_certificate         /etc/nginx/ssl/wordpress/wordpress.crt;
    ssl_certificate_key     /etc/nginx/ssl/wordpress/wordpress.key;
    #ssl_trusted_certificate /etc/nginx/ssl/path/ca-certs.pem;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   # don't use SSLv3 because of killer poodles


#Uncomment to enable the settings
#gzip  on;

location / {
 # app1 reverse proxy follow
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header Host $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass https://10.0.2.5:443;
}  
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#  #  #  #  #  #  #   #  Webserver 2  #  #  #  #  #  #  #  #  #  #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

server {
listen 443 ssl;
server_name owncloud.example.eu;


 ssl on;
     ssl_certificate         /etc/nginx/ssl/owncloud  /owncloud.crt;
     ssl_certificate_key     /etc/nginx/ssl/owncloud/owncloud.key;
     #ssl_trusted_certificate /etc/nginx/ssl/path/ca-certs.pem;
     ssl_ciphers  HIGH:!aNULL:!MD5;
     ssl_prefer_server_ciphers  on;
     ssl_session_cache    shared:SSL:1m;
     ssl_session_timeout  5m;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   # don't use SSLv3 because of killer poodles


#Uncomment to enable the settings
#gzip  on;

location / {
  # app1 reverse proxy follow
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass https://10.0.2.7:443;
} 
} 
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Did you set the SELinux? Maybe this article will help you: https://www.nginx.com/blog/nginx-se-linux-changes-upgrading-rhel-6-6/