Category Archives: Programming

Proxying Apache Connections to Multiple Applications

I was having issues getting Apache working with Plex, OwnCloud, and SyncThing at the same time on a new server. I wanted to have a reverse proxy set up, so instead of

http://server.com:32400/web/index.html
http://server.com:8384/syncthing/
http://server.com/owncloud

I could have

http://server.com/
http://server.com/syncthing
http://server.com/owncloud

Apache’s reverse proxy functionality caters to this need.
Each app gets its own ProxyPass, telling Apache what to do with incoming requests.
SyncThing didn’t like operating without a trailing slash in the URL, so a rewrite rule was created to do this for the user.
OwnCloud, since it doesn’t require operating on a separate port, simply goes around the proxy.
Everything else falls into the catchall, which redirects the user to Plex.

#redirect everything to SSL
<VirtualHost *:80>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:443>
        ServerName server.com

        #SSL configuration
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
        SSLCertificateChainFile /etc/ssl/certs/intermediate.crt
        
        #begin the proxying
        ProxyRequests Off
        ProxyPreserveHost On

        #let owncloud pass straight through
        ProxyPass /owncloud !

        #syncthing doesn't work without a trailing slash in browser URL
        RewriteRule ^/syncthing$ /syncthing/ [R]
        ProxyPass /syncthing/ http://127.0.0.1:8384/
        ProxyPassReverse /syncthing/ http://127.0.0.1:8384/

        #default go to plex
        ProxyPass / http://127.0.0.1:32400/
        ProxyPassReverse / http://127.0.0.1:32400/

        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^/web
        RewriteCond %{HTTP:X-Plex-Device} ^$
        RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>

Setting LD_LIBRARY_PATH in NetBeans Debugger

Currently in the process of taking legacy C++ code into C# with .NET. The legacy code was given to us in a VM with NetBeans powering the project. It currently requires starting the code externally through a terminal, and then attaching the debugger in NetBeans to the running process. Looking into it, the code was missing some LD_LIBRARY_PATH definitions that were set when the external script was run to start the application. Adding these paths into the local debugger would allow NetBeans to debug the application without needing to attach to an already running process.

To set the paths, go to Run > Set Project Configuration > Customize. Go to Run and then click the “…” next to Environment. Add an environment variable named “LD_LIBRARY_PATH” and the path syntax should look like:

$LD_LIBRARY_PATH:/usr/lib:/some/other/folder:/another/one

notice the “:”s separating each path.

After adding the page should look like:

Capture

Rebuild the project and debug!