Accessing my Tutor site with www

Hi, I was wondering if there is a way to access my site using www.examplesite.com. At the moment www.examplesite.com gets redirected to studio.examplesite.com. I don’t have that issue when I access site via examplesite.com without the “www”.

How do I resolve this issue? How do I add the www.examplesite.com to the site-enabled (nginx) and the configure it for the SSL Certificate? I have a feeling that the “www” prefix is being redirected to studio.examplesite.com due to that fact that the “www.examplesite.com” is not URLs enabled for SSL but please help me resolve this issue because most people that visit a website will type “www”

Hi @iwebhost4u! This is a great question. Out of the box there is no simple solution to redirect certain subdomains to the lms. But it’s possible with a small amount of hacking. First, you will have to add a custom nginx configuration file to the env/apps/nginx folder. Then you will have to generate the ssl certificate for the www subdomain from the host manually and restart the nginx service.
I’m writing this from my phone and will only be able to give more precise instructions once I get to a computer. Is that enough to get you started?

Hi Regis,

Thank you for response!

Please it will be great if you could provide more details.

Thanks for your time.

Eric

Step 1 : add the www.conf file to $(tutor config printroot)/env/apps/nginx. this file should contain:

server {
    server_name www.LMS_HOST;
    listen 80;
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/www.LMS_HOST/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.LMS_HOST/privkey.pem;
    return 301 https://LMS_HOST$request_uri;
}

Step 1.5: Stop platform tutor local stop

Step 2: generate SSL certificates. To do so, run:

docker run --volume "$(tutor config printroot)/data/letsencrypt:/etc/letsencrypt/" -p 80:80 --entrypoint=sh certbot/certbot:latest "-e" "-c" "certbot certonly --standalone -n --agree-tos -m admin@LMS_HOST -d www.LMS_HOST"

In both steps, don’t forget to replace all instances of LMS_HOST by your actual LMS host address (without “www”).

Step 3: restart platform: tutor local start -d.

I’m currently sitting in an airport and don’t have much time to test this, but it should work.

Thanks for the help, Regis! I tried the steps and I got the following error in step 2:
docker: Error response from daemon: driver failed programming external connectivity on endpoint distracted_antonelli (93678a02be5a290e439844a0b0760fa53a774c2faefd1f92b547f676b25f3076): Bind for 0.0.0.0:80 failed: port is already allocated.
ERRO[0000] error waiting for container: context canceled

Any help?

Actually, you should stop the nginx container prior to running step 2.

Thanks, Regis! It weird that now I am getting a different error message:

“No such file or directory”

I will start all over again and let you know what happens.

Ok, I don’t know what I’m doing wrong but this time I am getting the following error:

“sh: can’t open ‘certbot certonly --standalone -n --agree-tos -m admin@example.com -d www.example.com’: No such file or directory”

I followed exam same steps and I stop the ngix container as you suggested but the above error is the results.

Ok, the docker run command was wrong. Try the following:

docker run --volume "$(tutor config printroot)/data/letsencrypt:/etc/letsencrypt/" -p 80:80 --entrypoint=sh certbot/certbot:latest "-e" "-c" "certbot certonly --standalone -n --agree-tos -m admin@LMS_HOST -d www.LMS_HOST"

Please compare the changes in order to understand what is happening here.

(I edited my previous answer to reflect the changes)

Thanks a lot Regis!
The changes you made worked like a charm. Issue resolved and I am now able to access the site with the “www” subdomain.

Thanks again for your help!

Eric Mensah

1 Like

@iwebhost4u Hi, Éric, would please post the command to stop the nginx container. Thank you!

found it : tutor local stop nginx
Thanks

1 Like

Sorry, I saw this late.

Hi Regis, is this solution still valid per the current release of Tutor? It’s not working for me anymore.