User Tools

Site Tools


Sidebar

js#vista.png msort nsort

qnap:proxy_front_end

Reverse proxying for a QNap server

QNap is a pretty good investment for your data. The only pain I have had with it is the web UI that is partially hard-coded which makes reverse proxying a nightmare.

Here is the config that worked for me.:

  • QNap Server: 10.1.1.100
  • NASC123B8 = Self assigned hostname of QNap
  • Webserver on port 8080
  • 2nd Webserver on port 8081 for BackupPC
<VirtualHost *:443>
	ServerName qnas.domain.tld
	SSLEngine on
	SSLProtocol all -SSLv2
	SSLCertificateFile /etc/ssl/cert.pem
	SSLCertificateKeyFile /etc/ssl/key.key

	RewriteEngine on
	RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
	RewriteRule .* - [F]

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride AuthConfig
	</Directory>
	
        <Location /bu>
                SetOutputFilter INFLATE;proxy-html;DEFLATE
                ProxyHTMLExtended On
		ProxyHTMLDoctype XHTML
		ProxyPass http://10.1.0.100:8081/
                ProxyPassReverse http://10.1.0.100:8081/
                ProxyHTMLURLMap / /bu/
		ProxyHTMLURLMap 10.1.0.100:8081 qnap.domain.tld
		ProxyHTMLURLMap NASC123B8 qnap.domain.tld
		Substitute "s|/bu//bu/|//|in"
        </Location>

	<Location />
		authtype basic
		authname "Server External"
		authuserfile /some/safe/directory/.htpasswd
		require valid-user
		SetOutputFilter INFLATE;proxy-html;DEFLATE
		ProxyHTMLExtended on
		ProxyHTMLDoctype XHTML
                ProxyPass http://10.1.0.100:8080/
                ProxyPassReverse http://10.1.0.100:8080/
		AddOutputFilterByType SUBSTITUTE text/html
		AddOutputFilterByType SUBSTITUTE text/xml
		Substitute "s|8080|443|in"
		Substitute "s|http://|https://|in"
	</Location>
</VirtualHost>


<VirtualHost *:80>
    ServerName qnas.domain.tld
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
    RewriteCond %{REQUEST_URI} !^/nrd/
    RewriteCond %{REQUEST_URI} !^/images/
    RewriteCond %{REQUEST_URI} !^/css/
    RewriteCond %{REQUEST_URI} !^/javascript/
    RewriteCond %{REQUEST_URI} !^/vncterm/
    RewriteCond %{REQUEST_URI} !^/.*\.js$
    RewriteCond %{REQUEST_URI} !^/login.pl$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [L,R]
</VirtualHost>
qnap/proxy_front_end.txt · Last modified: 2020/02/24 11:16 (external edit)