Make it possible to configure the notes service hostname

This is important, in particular in development.
This commit is contained in:
Régis Behmo 2019-05-15 10:51:54 +02:00
parent 79ad1871d2
commit 2234510cfb
10 changed files with 25 additions and 17 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Latest
- [Improvement] Make it possible to configure the notes service hostname
## 3.3.10 (2019-05-15)
- [Bugfix] Fix boolean configuration choices

View File

@ -168,6 +168,7 @@ Student notes
*************
- ``ACTIVATE_NOTES`` (default: ``false``)
- ``NOTES_HOST`` (default: ``notes.{{ LMS_HOST }}``)
With `notes <https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-ironwood.master/exercises_tools/notes.html?highlight=notes>`_, students can annotate portions of the courseware.
@ -176,6 +177,8 @@ With `notes <https://edx.readthedocs.io/projects/open-edx-building-and-running-a
You should beware that the ``notes.<LMS_HOST>`` domain name should be activated and point to your server. For instance, if your LMS is hosted at http://myopenedx.com, the notes service should be found at http://notes.myopenedx.com.
If you would like to host the notes service at a different domain name, you can set the ``NOTES_HOST`` configuration variable. In particular, in development you should set this configuration variable to ``notes.localhost`` in order to be able to access the notes service from the LMS. Otherwise you will get a "Sorry, we could not search the store for annotations" error.
Xqueue
******

View File

@ -5,7 +5,7 @@ upstream notes-backend {
{% if ACTIVATE_HTTPS %}
server {
server_name notes.{{ LMS_HOST }};
server_name {{ NOTES_HOST }};
listen 80;
return 301 https://$server_name$request_uri;
}
@ -13,11 +13,11 @@ server {
server {
{% if ACTIVATE_HTTPS %}listen 443 {{ "" if WEB_PROXY else "ssl" }};{% else %}listen 80;{% endif %}
server_name notes.localhost notes.{{ LMS_HOST }};
server_name notes.localhost {{ NOTES_HOST }};
{% if ACTIVATE_HTTPS and not WEB_PROXY %}
ssl_certificate /etc/letsencrypt/live/notes.{{ LMS_HOST }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/notes.{{ LMS_HOST }}/privkey.pem;
ssl_certificate /etc/letsencrypt/live/{{ NOTES_HOST }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ NOTES_HOST }}/privkey.pem;
{% endif %}
# Disables server version feedback on pages and in headers

View File

@ -6,7 +6,7 @@ ALLOWED_HOSTS = [
"notes",
"notes.openedx",
"notes.localhost",
"notes.{{ LMS_HOST }}",
"{{ NOTES_HOST }}",
]
DATABASES = {

View File

@ -39,7 +39,7 @@
"EMAIL_PORT": {{ SMTP_PORT }},
"HTTPS": "{{ "on" if ACTIVATE_HTTPS else "off" }}",
{% if ACTIVATE_NOTES %}
"EDXNOTES_PUBLIC_API": "{{ "https" if ACTIVATE_HTTPS else "http" }}://notes.{{ LMS_HOST }}/api/v1",
"EDXNOTES_PUBLIC_API": "{{ "https" if ACTIVATE_HTTPS else "http" }}://{{ NOTES_HOST }}/api/v1",
"EDXNOTES_INTERNAL_API": "http://notes.openedx:8000/api/v1",
{% endif %}
"LANGUAGE_CODE": "{{ LANGUAGE_CODE }}",

View File

@ -41,6 +41,7 @@ MYSQL_HOST: "mysql"
MYSQL_PORT: 3306
NGINX_HTTP_PORT: 80
NGINX_HTTPS_PORT: 443
NOTES_HOST: "notes.{{ LMS_HOST }}"
NOTES_MYSQL_DATABASE: "notes"
NOTES_MYSQL_USERNAME: "notes"
RABBITMQ_HOST: "rabbitmq"

View File

@ -6,7 +6,7 @@ metadata:
spec:
rules:
{% set hosts = [LMS_HOST, "preview." + LMS_HOST, CMS_HOST] %}
{% if ACTIVATE_NOTES %}{% set hosts = hosts + ["notes." + LMS_HOST] %}{% endif %}
{% if ACTIVATE_NOTES %}{% set hosts = hosts + [NOTES_HOST] %}{% endif %}
{% for host in hosts %}
- host: {{ host }}
http:

View File

@ -27,14 +27,14 @@
{% if ACTIVATE_NOTES %}
<VirtualHost *:80>
ServerName notes.{{ LMS_HOST }}
ServerName {{ NOTES_HOST }}
Redirect / https://notes.{{ CMS_HOST }}/
</VirtualHost>
<VirtualHost *:443>
ServerName notes.{{ LMS_HOST }}
ServerName {{ NOTES_HOST }}
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/notes.{{ LMS_HOST }}/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/notes.{{ LMS_HOST }}/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/{{ NOTES_HOST }}/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/{{ NOTES_HOST }}/privkey.pem
ProxyPreserveHost On
ProxyRequests On
@ -45,7 +45,7 @@
{% else %}
<VirtualHost *:80>
ServerName {{ LMS_HOST }}
ServerAlias preview.{{ LMS_HOST }} {{ CMS_HOST }} {% if ACTIVATE_NOTES %}notes.{{ LMS_HOST }}{% endif %}
ServerAlias preview.{{ LMS_HOST }} {{ CMS_HOST }} {% if ACTIVATE_NOTES %}{{ NOTES_HOST }}{% endif %}
ProxyPreserveHost On
ProxyRequests On

View File

@ -36,7 +36,7 @@ server {
{% if ACTIVATE_NOTES %}
server {
listen 80;
server_name notes.{{ LMS_HOST }};
server_name {{ NOTES_HOST }};
server_tokens off;
location / {
@ -51,10 +51,10 @@ server {
{% if ACTIVATE_HTTPS %}
server {
listen 443 ssl;
server_name notes.{{ LMS_HOST }};
server_name {{ NOTES_HOST }};
ssl_certificate /etc/letsencrypt/live/notes.{{ LMS_HOST }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/notes.{{ LMS_HOST }}/privkey.pem;
ssl_certificate /etc/letsencrypt/live/{{ NOTES_HOST }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ NOTES_HOST }}/privkey.pem;
server_tokens off;
location / {

View File

@ -1,2 +1,2 @@
certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d {{ LMS_HOST }} -d {{ CMS_HOST }} -d preview.{{ LMS_HOST }}
{% if ACTIVATE_NOTES %}certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d notes.{{ LMS_HOST }}{% endif %}
{% if ACTIVATE_NOTES %}certbot certonly --standalone -n --agree-tos -m admin@{{ LMS_HOST }} -d {{ NOTES_HOST }}{% endif %}