peppy
Greetings,
I finally got Phoenix working on a sub-domain of my website. However, I still need to get an SSL certificate set up, and I’m getting weird errors. Here is my Apache configuration so far for the sub-domain:
<VirtualHost *:80>
ServerAdmin admin@mywebsite.com
ServerName ex.mywebsite.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =ex.mywebsite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@mywebsite.com
ServerName ex.mywebsite.com
DocumentRoot /home/username/mywebsite.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:4000/$1" [P,L]
ProxyRequests Off
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
ProxyPass /socket/ ws://127.0.0.1:4000/socket/
ProxyPassReverse /socket/ ws://127.0.0.1:4000/socket/
</VirtualHost>
Here is the command I run to try installing LetsEncrypt:
sudo certbot --http-01-port 4000 --authenticator webroot --webroot-path /home/username/mywebsite.com --installer apache -n -d ex.mywebsite.com
It results in this error:
Domain: ex.mywebsite.com
Type: unauthorized
Detail: Invalid response from
https://ex.mywebsite.com/.well-known/acme-challenge/n6pcuMgsQhBtpHd2reDEZpI57fZnVoPo1JbaUNopmtY
[***.***.***.***]: "<!DOCTYPE html>\n<html>\n<head>\n <meta
charset=\"utf-8\">\n <title>Phoenix.Router.NoRouteError at GET
/.well-known/acme-challen"
What should I do to get it to install correctly?
Also, for no particular reason, I’m using the same document root “/home/username/mywebsite.com” that I use for my main website. What is the standard practice for the location of the document root? Should I be using something like this instead: “/home/username/HelloWeb”? With HelloWeb being the folder where the my Phoenix project was installed?
Ultimately, I’ll probably just be loading up the Phoenix JavaScript as an external file “https://ex.mywebsite.com/js/app.js” through my main website “https://www.mywebsite.com” and developing my own front-end designs through the main website.
Thanks
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
derek-zhou
The error is because you are forwarding everything to phoenix, including the cerbot’s challenge, which is a static file generated on the fly by certbot. The easiest thing to do is to get the certbot working before setting up any reverse proxy. You do not nee the challenge response to renew the cert, only for the initial setup.
peppy
Thanks a lot, I greatly appreciate it. This did the trick.
peppy
Since it’s almost 90 days, LetsEncrypt is giving me errors that the auto renew is not working. I need some help getting LetsEncrypt installed correctly. As I’ve learned more about Phoenix, there have been some changes and I can’t remember how I got LetsEncrypt installed the first time.
Here is my setup for Apache:
Here is the LetsEncrypt certbot command I’m trying to use:
To begin with, I’m not sure if I’m using the <Location /*> correctly in Apache and how that translates to the certbot command for installing a certificate. The phoenix project works this way, but I’m not sure if it’s the proper way or not. On regular non-phoenix websites, I use a standard path like “/home/username/mysite.com”, so I’m not sure how this gets setup for the socket and proxy pass. I tried commenting out the proxy pass / socket stuff as well, but letsencrypt still fails.
Lastly, this is the error that comes up in the Phoenix logs:
How would you get this setup to work?
Thanks
maz
Just a stab in the dark here. Do you have .well-known as a static dir in endpoint.ex?
peppy
I do not. I’m not exactly sure what I’m supposed to do for this LetsEncrypt thing. Here is what I have:
/lib/exchat_web/endpoint.ex
Also: /lib/exchat_web/router.ex
I’ll need to know what to put into these files, and then what the LetsEncrypt command should be for the webroot path variable. It is tricky because these paths in the Phoenix app aren’t like normal paths in the Ubuntu operating system, which is what I usually use for LetsEncrypt
maz
In endpoint.ex, with respect to .well-known, I am using it to access apple-app-site-association file in there and this is how I successfully access it(note the “~w” line):
peppy
Thanks for the hint. Are you using a sub-domain for your setup?
I added .well-known to the “~w” line and ran the LetsEncrypt call:
sudo certbot certonly --webroot --webroot-path / -n -d ex.mysite.com --deploy-hook "systemctl reload apache2" --dry-runbut it’s still not working. The LetsEncrypt error comes up as:
Phoenix error:
maz
How about you try making a trivial
mytestfiletext file in.well-knownand try accessing it over http?peppy
I’m not even sure how to create a text file in .
well-knowninside Phoenix’s system. It’s not like the normal linux system that I am used to where you can justmkdir.well-known andvim mytestfileinside it. ‘.well-known’ inside phoenix isn’t even part of the linux filesystem for thecertbotcall. There are no tutorials or examples online (that I’ve found) for setting up LetsEncrypt on a subdomain / proxy pass system in apache.peppy
Ok, I did a little searching and came across your earlier post: Serving .well-known/apple-app-site-association Works in Development env but returns Phoenix.HTML.Safe error in Release - #3 by maz
So I was able to add a directory:
I’m still getting this error when running certbot: