ReverseProxy not working on OSX El Capitan

8,039

A couple of things that you need to look at here:

  1. Make sure that you are using the right config file. When I installed apache 2.4 on my El Capitan machine the main configs actually point to a different directory /usr/local/etc/apache2/2.4/httpd.conf:

    $ httpd -V
    Server version: Apache/2.4.17 (Unix)
    Server built:   Nov 13 2015 19:31:42
    Server's Module Magic Number: 20120211:51
    Server loaded:  APR 1.5.2, APR-UTIL 1.5.4
    Compiled using: APR 1.5.2, APR-UTIL 1.5.4
    Architecture:   64-bit
    Server MPM:     prefork
      threaded:     no
        forked:     yes (variable process count)
    Server compiled with....
     -D APR_HAS_SENDFILE
     -D APR_HAS_MMAP
     -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
     -D APR_USE_SYSVSEM_SERIALIZE
     -D APR_USE_PTHREAD_SERIALIZE
     -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     -D APR_HAS_OTHER_CHILD
     -D AP_HAVE_RELIABLE_PIPED_LOGS
     -D DYNAMIC_MODULE_LIMIT=256
     -D HTTPD_ROOT="/usr/local/Cellar/httpd24/2.4.17"
     -D SUEXEC_BIN="/usr/local/Cellar/httpd24/2.4.17/bin/suexec"
     -D DEFAULT_PIDLOG="/usr/local/var/run/apache2/httpd.pid"
     -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
     -D DEFAULT_ERRORLOG="logs/error_log"
     -D AP_TYPES_CONFIG_FILE="/usr/local/etc/apache2/2.4/mime.types"
     -D SERVER_CONFIG_FILE="/usr/local/etc/apache2/2.4/httpd.conf"
    
  2. For reverse proxy you can simply use something like this:

    <VirtualHost *:80>
      ServerName marvin.boldlygoingnowhere.org
      DocumentRoot /var/www/html
      ProxyPreserveHost On
      ProxyPass /plex http://127.0.0.1:32400
      ProxyPassReverse /plex http://127.0.0.1:32400
    
    </VirtualHost>
    
Share:
8,039

Related videos on Youtube

r2DoesInc
Author by

r2DoesInc

Updated on September 18, 2022

Comments

  • r2DoesInc
    r2DoesInc almost 2 years

    I am attempting to access my plex web ui through a cleaner url. Currently, you can access it at http://marvin.boldlygoingnowhere.org:32400/web/index.html. I want it to be at http://marvin.boldlygoingnowhere.org/plex

    Heres what I have,

    marvin:~ Marvin$ httpd -v Server version:

     Apache/2.4.16 (Unix)
    Server built:   Aug 22 2015 16:51:57
    Server's Module Magic Number: 20120211:47
    Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
    Compiled using: APR 1.4.8, APR-UTIL 1.5.2
    Architecture:   64-bit
    Server MPM:     prefork
      threaded:     no
        forked:     yes (variable process count)
    Server compiled with....
     -D APR_HAS_SENDFILE
     -D APR_HAS_MMAP
     -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
     -D APR_USE_FLOCK_SERIALIZE
     -D APR_USE_PTHREAD_SERIALIZE
     -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     -D APR_HAS_OTHER_CHILD
     -D AP_HAVE_RELIABLE_PIPED_LOGS
     -D DYNAMIC_MODULE_LIMIT=256
     -D HTTPD_ROOT="/usr"
     -D SUEXEC_BIN="/usr/bin/suexec"
     -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
     -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
     -D DEFAULT_ERRORLOG="logs/error_log"
     -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
     -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
    

    In

    /private/etc/apache2/extra/httpd-vhosts.conf

    Listen 80
    
        # Listen for virtual host requests on all IP addresses
        <VirtualHost *:80>
            ServerName marvin.boldlygoingnowhere.org
            ErrorLog "/private/var/log/apache2/marvin-error_log"
            CustomLog "/private/var/log/apache2/marvin-access_log" common
            ServerAdmin [email protected]
            ProxyRequests Off
    
            <Proxy http://marvin.boldlygoingnowhere.org/plex>
    
              Order deny,allow
              Allow from all
    
              ProxyPreserveHost off
              ProxyPass http://localhost:32400
              ProxyPassReverse http://localhost:32400
    
            </Proxy>
        </VirtualHost>
    

    /private/etc/apache2/httpd.conf

    Uncommented

    Include /private/etc/apache2/extra/httpd-vhosts.conf

    and

    LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so

    My expectation with this current setup is to be able to reach http://marvin.boldlygoingnowhere.org/plex/web, instead I get a 404.

    I am a mobile software engineer, but this is one of my first adventures into networking and its beating me down pretty hard.

    • Diamond
      Diamond over 8 years
      @r2Doeslnc, Can you please check with: ProxyPass /web http://localhost:32400/web ProxyPassReverse /web http://localhost:32400/web
    • Diamond
      Diamond over 8 years
      you also need to have mod_proxy enabled.
    • Diamond
      Diamond over 8 years
      Well, my mistake. With my previous config you can get to http://marvin.boldlygoingnowhere.org/web. But you need: ProxyPass /plex http://localhost:32400/web ProxyPassReverse /plex http://localhost:32400/web. This should work if mod_proxy is already enabled. You will need to restart apache whenever you make changes to a config file.
    • r2DoesInc
      r2DoesInc over 8 years
      My module dump can be seen pastebin.com/EYaNc39f. I followed the instruction here - linuxquestions.org/questions/linux-newbie-8/… - to enable mod_proxy. You can see by the minor error with xml2enc that mod_proxy is at least being looked at.
    • Diamond
      Diamond over 8 years
      Have you tried with the changes I suggested?
    • r2DoesInc
      r2DoesInc over 8 years
      Yes. Those are the settings currently in place. Both marvin.boldlygoingnowhere.org/plex and marvin.boldlygoingnowhere.org/web lead to an apache 404.
    • Diamond
      Diamond over 8 years
      Are you able to reach http://localhost:32400/web locally?
    • r2DoesInc
      r2DoesInc over 8 years
      Yes, and marvin.boldlygoingnowhere.org:32400/web locally and remotely.
  • r2DoesInc
    r2DoesInc over 8 years
    See updated output.
  • r2DoesInc
    r2DoesInc over 8 years
    Using your example, I get an apache 404. "The requested URL /plex was not found on this server."
  • r2DoesInc
    r2DoesInc over 8 years
    Yes, that link is what I started working off of. I have more than just plex that I wanted to setup, so I was just attempting to get the basics understood so I could extend them to my specifics. Since using the plex.tv link would only solve the issue for one of my services, its not the route I really want to take.
  • Diamond
    Diamond over 8 years
    I have edited my answer, and as I have mentioned, you need to investigate your apache log files. I have also pointed two basic configuration errors. You can post your error log too.
  • r2DoesInc
    r2DoesInc over 8 years
    Mod proxy is doing SOMETHING. My /var/log/apache2/service_proxy_error.log output from when I access /plex pastebin.com/huduKdLb. My /var/log/apache2/access_log when I access it, pastebin.com/JaS8duGN
  • Diamond
    Diamond over 8 years
    Well it seems like an well known OS X issue. They have made some changes how reverse proxy used to work on the platform. Check here: (github.com/phpmyadmin/phpmyadmin/issues/11503) and here: (discussions.apple.com/thread/7231060)
  • r2DoesInc
    r2DoesInc over 8 years
    Ive run into the SSL thing a few times after setting up some redirects, that was going to be next on my list of things to tackle. Im not sure how this relates to my proxy issue though, can you clarify a bit?
  • Diamond
    Diamond over 8 years
    Pls check the 2nd link above. There are also some hints to deal with the issue.
  • r2DoesInc
    r2DoesInc over 8 years
    Unfortunately I need a bit more than hints. From what I can see, what I have SHOULD work. I have updated my sites config in /Library/Server/Web/Config/apache2/sites/ to include the proxypass info, but still nothing. I do not have a custom sites file as mentioned in that link. That link basically recommends just restoring an older Server.app.
  • r2DoesInc
    r2DoesInc over 8 years
    The logs seem to be reporting that its working. I do not know what I am missing. pastebin.com/nxJ5QT8c
  • r2DoesInc
    r2DoesInc over 8 years
  • Rico
    Rico over 8 years
    Are you overriding your VirtualHost directive somewhere else? Seems like you may have another VirtualHost *:80 somewhere else too, that is basically undefining anything that goes to /plex Thus you are getting a 404 (not found)
  • r2DoesInc
    r2DoesInc over 8 years
    The config in /Applications/Server.app/Contents/ServerRoot/Library/Server/‌​Web/Config/Proxy/apa‌​che_serviceproxy.con‌​f has one that was generated by the OSX Server App. You can see the details about that here - discussions.apple.com/thread/7231060
  • Rico
    Rico over 8 years
    how did you install apache ? brew?
  • r2DoesInc
    r2DoesInc over 8 years
    I created a backup of that config, and then deleted that virtual host and restarted apache. Still got the 404 error.
  • r2DoesInc
    r2DoesInc over 8 years
    apache was already installed by osx. i used apxs to install the extra modules.
  • r2DoesInc
    r2DoesInc over 8 years
    It is interestingly enough showing the plex favicon.
  • r2DoesInc
    r2DoesInc over 8 years
    Could the problem be related to the "Allow folder listing" option I have enabled to allow me to serve files? Without that enabled, everything redirects to https.
  • r2DoesInc
    r2DoesInc over 8 years
    Could the problem be related to the "Allow folder listing" option I have enabled to allow me to serve files? Without that enabled, everything redirects to https.
  • Rico
    Rico over 8 years
    @r2DoesInc yeah could be. you probably have a redirect directive somewhere too if you are redirecting everything going to port 80 to port 443. Do you have a VirtualHost *:443 directive somewhere? It's hard to see without getting a full config with all included files.
  • Diamond
    Diamond over 8 years
    I have noticed one thing, when you browse marvin.boldlygoingnowhere.org, it goes to your apache root directory. I think your virtual host entry is ignored somehow. Can you try with another hostname? like: plex.boldlygoinganywhere.org, you will need to add that in dns. Or see the beginning part here: coolestguidesontheplanet.com/…, on how to setup vhost in user directory instead.