<VirtualHost *:80>
	ServerName mqtt.example.com
	ServerAdmin webmaster@localhost
	
	DocumentRoot /var/www/html

	# Reverse Proxy for HTTP-MQTT-Bridge
	ProxyPass / http://localhost:8090/
	ProxyPassReverse / http://localhost:8090/
	# Static auth header (hmb:hmb)
	#RequestHeader set "Authorization" "Basic aG1iOmhtYg=="

	# Configure CORS headers
	Header always set "Access-Control-Allow-Origin" "*"
	Header always set "Access-Control-Allow-Methods" "GET, POST, OPTIONS"
	Header always set "Access-Control-Allow-Headers" "Content-Type"

	# Stop CORB complaints by overwriting text/html with application/json
	Header always set "Content-Type" "application/json"

	# Make OPTIONS request work by forcibly returning a 200 OK header
	# even though the backend returns a 405
	RewriteEngine on
	RewriteCond %{REQUEST_METHOD} OPTIONS
	RewriteRule ^(.*)$ $1 [R=200,L]

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet