502 Bad Gateway with nginx + apache + subversion + ssl (SVN COPY)

nginx 502
502 bad gateway nginx ubuntu
502 bad gateway nginx docker
502 bad gateway nginx centos
502 bad gateway nginx localhost
nginx reverse proxy 502 bad gateway
502 bad gateway nginx location
502 bad gateway nginx laravel

I'm having a problem running Apache + Subversion with SSL behind an Nginx proxy and I'm hoping someone might have the answer. I've scoured google for hours looking for the answer to my problem and can't seem to figure it out. What I'm seeing are "502 (Bad Gateway)" errors when trying to MOVE or COPY using subversion; however, checkouts and commits work fine. Here are the relevant parts (I think) of the nginx and apache config files in question:


upstream subversion_hosts {

server {
        listen       x.x.x.x:80;
        server_name  hostname;

        access_log   /srv/log/nginx/http.access_log main;
        error_log    /srv/log/nginx/http.error_log info;

        # redirect all requests to https
        rewrite ^/(.*)$ https://hostname/$1 redirect;

# HTTPS server
server {
        listen       x.x.x.x:443;
        server_name  hostname;

        passenger_enabled    on;
        root /path/to/rails/root;

        access_log   /srv/log/nginx/ssl.access_log main;
        error_log    /srv/log/nginx/ssl.error_log info;

        ssl                  on;
        ssl_certificate      server.crt;
        ssl_certificate_key  server.key;

        add_header Front-End-Https on;

        location /svn {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                set $fixed_destination $http_destination;
                if ( $http_destination ~* ^https(.*)$ )
                    set $fixed_destination http$1;
                proxy_set_header Destination $fixed_destination;

                proxy_pass http://subversion_hosts;


<VirtualHost *:80>
        # in order to support COPY and MOVE, etc -  over https (443),
        # ServerName _must_ be the same as the nginx servername
        # http://trac.edgewall.org/wiki/TracNginxRecipe
        ServerName hostname
        UseCanonicalName on

        <Location /svn>
                DAV svn
                SVNParentPath "/srv/svn"
                Order deny,allow
                Deny from all
                Satisfy any
                # Some config omitted ...

        ErrorLog /var/log/apache2/subversion_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/subversion_access.log combined

From what I could tell while researching this problem, the server name has to match on both the apache server as well as the nginx server, which I've done. Additionally, this problem seems to stick around even if I change the configuration to use http only.

NGINX 502 Bad Gateway: PHP-FPM, 502 Proxy Error; HTTP 502; 502 Bad Gateway NGINX. You can see in greater detail what the error specifically entails by going to your web� When Google services, like Google Search or Gmail, are experiencing a 502 Bad Gateway, they often show Server Error, or sometimes just 502, on the screen. Cause of 502 Bad Gateway Errors Bad Gateway errors are often caused by issues between online servers that you have no control over.

The previous solutions did not work for me, I had to change the nginx configuration and add the following in the location block, before the proxy_pass directive:

set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ ) {
    set $fixed_destination http$1;
proxy_set_header Destination $fixed_destination;
proxy_set_header Host $http_host;

NGINX 502 Bad Gateway: Gunicorn, Hello friends want a help from you! Because then I'm having a problem Error 502 Bad gateway always nginx. Everything was normal, but until� The Best Tech Newsletter Anywhere. Join 250,000 subscribers and get a daily digest of news, geek trivia, and our feature articles.

I found out that the cause of my problem was not the proxy between nginx and apache, but rather was an issue with Apache itself.

What I didn't mention in the original question was what was in the # Some config omitted. This block contained the following:

AuthType Basic
AuthName "Redmine SVN Repository"
Require valid-user
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler

For suberversion, I'm controlling user access using Redmine's authentication handler. After turning options on and off and narrowing down the problem, I learned that their authentication module is not thread-safe. I was running into the error because Apache was using the Worker MPM. Switching to the Prefork MPM (sudo aptitude install apache2-mpm-prefork in Ubuntu) resolved the issue.

How to Solve 502 Bad Gateway Issues?, 502 Bad Gateway Nginx commonly occurs when Nginx runs as a reverse proxy, and is unable to connect to backend services. This can be due� This post is part of a series on troubleshooting NGINX 502 Bad Gateway errors. If you’re not using PHP-FPM, check out our other article on troubleshooting NGINX 502s with Gunicorn as a backend. PHP-FastCGI Process Manager is a daemon for handling web server requests for PHP applications. In production, PHP-FPM is often deployed behind an

In my case, I was using RouixSVN and I only had to clear the SVN authentication data on my computer and log in again and it worked. Hope it helps someone else.

502 bad gateway nginx, Are you seeing a 502 bad gateway error when trying to access your all of the software resources required to run the site (Linux, NGINX, PHP,� 502 bad gateway nginx Posted September 1, 2016 291.6k views Ubuntu Linux Commands. By joilson. Hello friends want a help from you! Because then I’m having a problem

502 bad gateway in Nginx: Top 5 reasons for it, & how to resolve, As mentioned, a 502 Bad Gateway Error means that a server that is upstream to one that you (the client ) are connecting to has run into trouble. In� Still receiving bad gateway message. Again, this is with Ethernet cable from PC to LAN 1 with no other connections made to the router. I then reset router for 30 sec (read somewhere this might be actually reset certificate), cleared all cookies and still “502 Bad Gateway.” Help please.

How to Fix a 502 Bad Gateway Error on Your WordPress Site, Find out the cause of the 502 Bad Gateway Error and how to easily fix NGINX won't get any data from them, resulting in a 502 Bad Gateway� Fortunately, there are seven common and effective solutions for analyzing and fixing most of the causes of 502 Bad Gateway Errors. The tactics discussed below provide general fixes for 502 Bad Gateway Errors. If you have a WordPress site, this issue may require WordPress-specific solutions.

502 Bad Gateway Error: What It Is and How to Fix It, Today in this video you will learn about How to Fix “502 Bad Gateway”Nginx Error| Step By Step Duration: 1:14 Posted: Sep 1, 2019

  • I had tried that in the past, but figured it was worth a shot again. Unfortunately for me, that did not do the trick.
  • i added this line but it not works for years. today i removed this line and it works now
  • While this is a working suggestion, this is NOT a correct suggestion. More correct is to teach nginx to send fixed Destination header according to changed scheme.
  • This does work but would you please explain what this code actually does?
  • The Destination header is used for COPY and MOVE methods (tools.ietf.org/html/rfc2518#page-54). If we serve SSL/TLS with nginx and use Apache with mod_dav_svn as backend, the latter does not know about the https:// URI. With this snippet we strip the s from the https in the Destination header to match what Apache/Subversion is serving. The Host header is set to the original HTTP_HOST value from the client.
  • Thanks a lot mate