-
Notifications
You must be signed in to change notification settings - Fork 27
Django
If you have set up your Django application to run at the root of the domain (e.g., Django serves up the pages at http://example.com), then you'll likely have trouble validating your certificate request. Considering your website serves the app "example_com" at the root, we will do the following:
- Go into your webfaction control panel -> domains/websites -> websites
- Click on your existing django website
- Click "Add an application" and Choose "Create a new application"
- Name it something like "example_com_letsencrypt". (We're simply appending "_letsencrypt" to help identify which app this goes to.
- Choose app category "static" and app type should be "Static/cgi/php-7.2" (the no .htaccess option will likely work as well)
- Set the url to ".well-known"
- Click Save
- ssh into your webfaction server
- Open
~/letsencrypt_webfaction.toml
for editing (assuming here you've already done the install steps of letsencrypt_webfaction. If not do those now.) - Add a new certificate entry and specify the authentication key to be saved
to
~/webapps/example_com_letsencrypt
(our new app directory) - Run
letsencrypt_webfaction run
. It may complain that it can't access the file in the new app we created. Thats ok, next step explains and fixes it. - Webfaction will serve it up as
http://example.com/.well-known/.well-known/acme-challenge/certificate_key
. We need to make sure it can also be served up ashttp://example.com/.well-known/acme-challenge/certificate_key
. To do this we can create a symbolic link by running the following command:ln -s ~/webapps/example_com_letsencrypt/.well-known/acme-challenge ~/webapps/example_com_letsencrypt/acme-challenge
- You can run
letsencrypt_webfaction run
again if you like to verify it is setup correctly. You should now get a better response.
In the below instructions, replace example_com
with the domain in question.
-
In the WebFaction control panel, add a new static application titled something like
example_com_redirect_to_https
. -
Create an .htaccess file at
~/webapps/example_com_redirect_to_https/.htaccess
with the following contents:RewriteEngine on RewriteRule !^.well-known($|/) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This will redirect http traffic to https as per the WebFaction documentation and this StackOverflow post.
-
In the WebFaction control panel, change your domain and subdomains to HTTPS in the panel to edit the website properties.
-
In the WebFaction control panel, create a new website for the new static application you created in step #1.
- Normal website (http)
- Domains - Add your domain and every subdomain that you would like redirected from http to https.
- Contents - Add the new application you created in step #1.
-
Use the command with the static app root dir (
--public ~/webapps/example_com_redirect_to_https
) -
After that an email should be sent to support to install the certificate for the specified domain (and subdomains).
-
Go to your webfaction console and under Domains/Websites verify the SSL cert has been added on the SSL panel
-
Associate this with the SSL application you created above. Note that you will need to switch from the shared certificate set in step 3, to the certificate created in step 5 in the security dropdown list for the website.
Alias your apache config to point at a different folder: https://github.com/will-in-wi/letsencrypt-webfaction/issues/85