What I want to achieve is when I browse for http://example.com:8080 it gets redirected to https://example.com:8080.
My web application is written in Django, and I have the following line in my settings:
SECURE_SSL_REDIRECT = True The httpd configuration for example.com looks like this:
LISTEN 8080 <VirtualHost *:8080> ServerName example.com SSLEngine on SSLCertificateFile /path_to_cer SSLCertificateKeyFile /path_to_key SSLCertificateChainFile /path_to_iterm.cer RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} Alias /static /path_to_mysite/static <Directory /path_to_mysite/static> Require all granted </Directory> <Directory /path_to_mysite_wsgi_dir> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess mysite python-path=/path_to_mysite:/path_to_mysite_python_packages display-name=%{GROUP} WSGIProcessGroup mysite WSGIApplicationGroup %{GLOBAL} WSGIScriptAlias / /path_to_mysite_wsgi.py </VirtualHost> with these configurations when I browse http://example.com, I will get the following error:
Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please. any thoughts?
python-pathto point at your virtual environment site packages. Read modwsgi.readthedocs.io/en/develop/user-guides/… to see how to configure virtual environment correctly.python-hometo point at my virtual environment, and settingpython-pathresolved the issues (unfortunately I don't remember what was the problem). But now because of your comment, I removedpython-path, and usedpython-homeinstead and it seems everything is working fine! I have no clue why :D