<VirtualHost *:80>
   ServerName findword.missclick.net
   Redirect permanent / https://findword.missclick.net/
</VirtualHost>

<VirtualHost *:443>
	ServerAdmin admin@missclick.net
	ServerName findword.missclick.net
	ServerAlias www.findword.missclick.net
	DocumentRoot /home/dev/findword
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined


        ProxyPass /ws/ ws://127.0.0.1:8001/
        ProxyPassReverse /ws/ ws://127.0.0.1:8001/

       RewriteEngine on
       RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
       RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
       RewriteRule .* ws://127.0.0.1:8001%{REQUEST_URI} [P,QSA,L]
       ProxyPass /wss/ wss://127.0.0.1:8001/
       ProxyPassReverse /wss/ wss://127.0.0.1:8001/

        ProxyPreserveHost On
        ProxyVia On
        ProxyTimeout 600

	Alias /static /home/dev/findword/static
	<Directory /home/dev/findword/static>
		Require all granted
	</Directory>
	
	Alias /media /home/dev/findword/media
	<Directory /home/dev/findword/media>
		Require all granted
	</Directory>

	<Directory /home/dev/findword/findword>
		<Files wsgi.py>
			Require all granted
		</Files>
	</Directory>

	WSGIDaemonProcess findword python-path=/home/dev/findword python-home=/home/dev/venv 
	WSGIProcessGroup findword
	WSGIPassAuthorization On
	WSGIScriptAlias / /home/dev/findword/findword/wsgi.py

	RedirectMatch 301 ^/$ /findword        
	SSLCertificateFile /etc/letsencrypt/live/findword.missclick.net/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/findword.missclick.net/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>
