mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-11 09:35:06 +00:00
Add scheme and server name to access logs
To do so, we had to create a new log_format. Plugin developers are strongly encouraged to start using this log format by adding the `access_log /var/log/nginx/access.log tutor;` directive to their extra nginx configurations. In order to load this log format early, the `tutor.conf` config file had to be renamed to something early in the alphabet... (hence starting by an underscore) Older users would face an error on nginx reload, so older "tutor.conf" files are automatically removed on config save.
This commit is contained in:
parent
0cf8958e3a
commit
08606ca1a6
@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- [Improvement] Modify nginx access logs to include request scheme and server name (plugin developers should use the "tutor" log format)
|
||||||
- [Bugfix] Fix DNS resolution of restarted service
|
- [Bugfix] Fix DNS resolution of restarted service
|
||||||
- [Feature] Restart multiple services with `local restart`
|
- [Feature] Restart multiple services with `local restart`
|
||||||
- [Feature] Make it possible to easily reload openedx gunicorn process with `tutor local exec lms reload-gunicorn``
|
- [Feature] Make it possible to easily reload openedx gunicorn process with `tutor local exec lms reload-gunicorn``
|
||||||
|
@ -181,9 +181,18 @@ def save(root, config):
|
|||||||
if plugin.templates_root:
|
if plugin.templates_root:
|
||||||
save_plugin_templates(plugin, root, config)
|
save_plugin_templates(plugin, root, config)
|
||||||
|
|
||||||
|
upgrade_obsolete(root)
|
||||||
fmt.echo_info("Environment generated in {}".format(base_dir(root)))
|
fmt.echo_info("Environment generated in {}".format(base_dir(root)))
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade_obsolete(root):
|
||||||
|
# tutor.conf was renamed to _tutor.conf in order to be the first config file loaded
|
||||||
|
# by nginx
|
||||||
|
nginx_tutor_conf = pathjoin(root, "apps", "nginx", "tutor.conf")
|
||||||
|
if os.path.exists(nginx_tutor_conf):
|
||||||
|
os.remove(nginx_tutor_conf)
|
||||||
|
|
||||||
|
|
||||||
def save_plugin_templates(plugin, root, config):
|
def save_plugin_templates(plugin, root, config):
|
||||||
"""
|
"""
|
||||||
Save plugin templates to plugins/<plugin name>/*.
|
Save plugin templates to plugins/<plugin name>/*.
|
||||||
|
10
tutor/templates/apps/nginx/_tutor.conf
Normal file
10
tutor/templates/apps/nginx/_tutor.conf
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Allow long domain names
|
||||||
|
server_names_hash_bucket_size 128;
|
||||||
|
|
||||||
|
# Set a short ttl for proxies to allow restarts
|
||||||
|
resolver 127.0.0.1 [::1]:5353 valid=10s;
|
||||||
|
|
||||||
|
# Configure logging to include scheme and server name
|
||||||
|
log_format tutor '$remote_addr - $remote_user [$time_local] $scheme://$host "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
@ -20,6 +20,7 @@ server {
|
|||||||
ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log tutor;
|
||||||
client_max_body_size 100M;
|
client_max_body_size 100M;
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ upstream lms-backend {
|
|||||||
server {
|
server {
|
||||||
server_name {{ LMS_HOST }} preview.{{ LMS_HOST }};
|
server_name {{ LMS_HOST }} preview.{{ LMS_HOST }};
|
||||||
listen 80;
|
listen 80;
|
||||||
|
access_log /var/log/nginx/access.log tutor;
|
||||||
return 301 https://$server_name$request_uri;
|
return 301 https://$server_name$request_uri;
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -20,6 +21,7 @@ server {
|
|||||||
ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log tutor;
|
||||||
client_max_body_size 4M;
|
client_max_body_size 4M;
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
# Allow long domain names
|
|
||||||
server_names_hash_bucket_size 128;
|
|
||||||
|
|
||||||
# Set a short ttl for proxies to allow restarts
|
|
||||||
resolver 127.0.0.1 [::1]:5353 valid=10s;
|
|
Loading…
Reference in New Issue
Block a user