removes redundant usage of FRONTEND_HOST variable (#102)

This commit is contained in:
Markos Gogoulos 2021-03-21 20:36:32 +02:00 committed by GitHub
parent 3b35ce0262
commit 2552551662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 61 deletions

View File

@ -87,7 +87,7 @@ git clone https://github.com/mediacms-io/mediacms
cd mediacms cd mediacms
``` ```
The default option to serve MediaCMS is on http://localhost. If you want to set a url and have it served there, set the `FRONTEND_HOST` variable on file `deploy/docker/local_settings.py`. The default option is to serve MediaCMS on all ips available of the server (including localhost).
Now run Now run
@ -95,7 +95,7 @@ Now run
docker-compose up docker-compose up
``` ```
This will download all MediaCMS related Docker images and start all containers. Once it finishes, MediaCMS will be installed and available on http://localhost (or the url you've set as `FRONTEND_HOST` on file `deploy/docker/local_settings.py`) This will download all MediaCMS related Docker images and start all containers. Once it finishes, MediaCMS will be installed and available on http://localhost or http://ip
For more instructions, checkout the docs on the [Docker deployment](docs/Docker_deployment.md) page. Docker Compose support has been contributed by @swiftugandan. For more instructions, checkout the docs on the [Docker deployment](docs/Docker_deployment.md) page. Docker Compose support has been contributed by @swiftugandan.

View File

@ -42,7 +42,11 @@ ALLOW_RATINGS_CONFIRMED_EMAIL_ONLY = True
# ip of the server should be part of this # ip of the server should be part of this
ALLOWED_HOSTS = ["*", "mediacms.io", "127.0.0.1", "localhost"] ALLOWED_HOSTS = ["*", "mediacms.io", "127.0.0.1", "localhost"]
FRONTEND_HOST = "http://localhost" FRONTEND_HOST = "http://localhost"
# this variable - along with SSL_FRONTEND_HOST is used on several places
# as email where a URL need appear etc
# FRONTEND_HOST needs an http prefix - at the end of the file # FRONTEND_HOST needs an http prefix - at the end of the file
# there's a conversion to https with the SSL_FRONTEND_HOST env # there's a conversion to https with the SSL_FRONTEND_HOST env
INTERNAL_IPS = "127.0.0.1" INTERNAL_IPS = "127.0.0.1"

View File

@ -7,15 +7,15 @@ server {
error_log /var/log/nginx/mediacms.io.error.log warn; error_log /var/log/nginx/mediacms.io.error.log warn;
# redirect to https if logged in # # redirect to https if logged in
if ($http_cookie ~* "sessionid") { # if ($http_cookie ~* "sessionid") {
rewrite ^/(.*)$ https://localhost/$1 permanent; # rewrite ^/(.*)$ https://localhost/$1 permanent;
} # }
# redirect basic forms to https # # redirect basic forms to https
location ~ (login|login_form|register|mail_password_form)$ { # location ~ (login|login_form|register|mail_password_form)$ {
rewrite ^/(.*)$ https://localhost/$1 permanent; # rewrite ^/(.*)$ https://localhost/$1 permanent;
} # }
location /static { location /static {
alias /home/mediacms.io/mediacms/static ; alias /home/mediacms.io/mediacms/static ;

View File

@ -37,4 +37,4 @@ The reverse proxy (`jwilder/nginx-proxy`) can be configured to provide SSL termi
The architecture below generalises all the deployment scenarios above, and provides a conceptual design for other deployments based on kubernetes and docker swarm. It allows for horizontal scaleability through the use of multiple mediacms_web instances and celery_workers. For large deployments, managed postgres, redis and storage may be adopted. The architecture below generalises all the deployment scenarios above, and provides a conceptual design for other deployments based on kubernetes and docker swarm. It allows for horizontal scaleability through the use of multiple mediacms_web instances and celery_workers. For large deployments, managed postgres, redis and storage may be adopted.
![MediaCMS](images/architecture.png) ![MediaCMS](images/architecture.png)

View File

@ -5,12 +5,7 @@ from .methods import is_mediacms_editor, is_mediacms_manager
def stuff(request): def stuff(request):
"""Pass settings to the frontend""" """Pass settings to the frontend"""
ret = {} ret = {}
if request.is_secure(): ret["FRONTEND_HOST"] = request.build_absolute_uri('/')
# in case session is https, pass this setting so
# that the frontend uses https too
ret["FRONTEND_HOST"] = settings.SSL_FRONTEND_HOST
else:
ret["FRONTEND_HOST"] = settings.FRONTEND_HOST
ret["DEFAULT_THEME"] = settings.DEFAULT_THEME ret["DEFAULT_THEME"] = settings.DEFAULT_THEME
ret["PORTAL_NAME"] = settings.PORTAL_NAME ret["PORTAL_NAME"] = settings.PORTAL_NAME
ret["LOAD_FROM_CDN"] = settings.LOAD_FROM_CDN ret["LOAD_FROM_CDN"] = settings.LOAD_FROM_CDN

View File

@ -1,37 +1,37 @@
MediaCMS.url = { MediaCMS.url = {
home: "{{FRONTEND_HOST}}", home: "/",
search: "{{FRONTEND_HOST}}/search", search: "/search",
latestMedia: "{{FRONTEND_HOST}}/latest", latestMedia: "/latest",
featuredMedia: "{{FRONTEND_HOST}}/featured", featuredMedia: "/featured",
recommendedMedia: "{{FRONTEND_HOST}}/recommended", recommendedMedia: "/recommended",
members: "{{FRONTEND_HOST}}/members", members: "/members",
/* Error pages */ /* Error pages */
error404: "{{FRONTEND_HOST}}/error", error404: "/error",
/* Taxonomies pages */ /* Taxonomies pages */
tags: "{{FRONTEND_HOST}}/tags", tags: "/tags",
categories: "{{FRONTEND_HOST}}/categories", categories: "/categories",
topics: "{{FRONTEND_HOST}}/topics", topics: "/topics",
languages: "{{FRONTEND_HOST}}/languages", languages: "/languages",
countries: "{{FRONTEND_HOST}}/countries", countries: "/countries",
/* User pages */ /* User pages */
likedMedia: "{{FRONTEND_HOST}}/liked", likedMedia: "/liked",
history: "{{FRONTEND_HOST}}/history", history: "/history",
/* Add/edit pages */ /* Add/edit pages */
addMedia: "{{FRONTEND_HOST}}/upload", addMedia: "/upload",
/* User account pages */ /* User account pages */
editProfile: "{{user.edit_url}}", editProfile: "{{user.edit_url}}",
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
signout: "{{FRONTEND_HOST}}/accounts/logout/", signout: "/accounts/logout/",
editChannel: "{{user.default_channel_edit_url}}", editChannel: "{{user.default_channel_edit_url}}",
changePassword: "{{FRONTEND_HOST}}/accounts/password/change/", changePassword: "/accounts/password/change/",
/* Administration pages */ /* Administration pages */
{% if IS_MEDIACMS_ADMIN %}admin: '/admin',{% endif %} {% if IS_MEDIACMS_ADMIN %}admin: '/admin',{% endif %}
/* Management pages */ /* Management pages */
{% if IS_MEDIACMS_ADMIN or IS_MEDIACMS_MANAGER or IS_MEDIACMS_EDITOR %}manageMedia: "{{FRONTEND_HOST}}/manage/media",{% endif %} {% if IS_MEDIACMS_EDITOR %}manageMedia: "/manage/media",{% endif %}
{% if IS_MEDIACMS_ADMIN or IS_MEDIACMS_MANAGER %}manageUsers: "{{FRONTEND_HOST}}/manage/users",{% endif %} {% if IS_MEDIACMS_MANAGER %}manageUsers: "/manage/users",{% endif %}
{% if IS_MEDIACMS_ADMIN or IS_MEDIACMS_MANAGER or IS_MEDIACMS_EDITOR %}manageComments: "{{FRONTEND_HOST}}/manage/comments",{% endif %} {% if IS_MEDIACMS_EDITOR %}manageComments: "/manage/comments",{% endif %}
{% else %} {% else %}
signin: "{{FRONTEND_HOST}}/accounts/login/", signin: "/accounts/login/",
register: "{{FRONTEND_HOST}}/accounts/signup/", register: "/accounts/signup/",
{% endif %} {% endif %}
}; };

View File

@ -1,8 +1,8 @@
MediaCMS.site = { MediaCMS.site = {
id: 'mediacms', id: 'mediacms',
title: "{{PORTAL_NAME}}", title: "{{PORTAL_NAME}}",
url: '{{FRONTEND_HOST}}/', url: '{{FRONTEND_HOST}}',
api: '{{FRONTEND_HOST}}/api/v1', api: '{{FRONTEND_HOST}}api/v1',
theme: { theme: {
mode: 'light', // Valid values: 'light', 'dark'. mode: 'light', // Valid values: 'light', 'dark'.
switch: { switch: {
@ -11,12 +11,12 @@ MediaCMS.site = {
}, },
logo:{ logo:{
lightMode:{ lightMode:{
img: "{{FRONTEND_HOST}}/static/images/logo_dark.png", img: "/static/images/logo_dark.png",
svg: "{{FRONTEND_HOST}}/static/images/logo_dark.svg", svg: "/static/images/logo_dark.svg",
}, },
darkMode:{ darkMode:{
img: "{{FRONTEND_HOST}}/static/images/logo_light.png", img: "/static/images/logo_light.png",
svg: "{{FRONTEND_HOST}}/static/images/logo_light.svg", svg: "/static/images/logo_light.svg",
}, },
}, },
pages: { pages: {
@ -49,4 +49,5 @@ MediaCMS.site = {
title: 'Categories', title: 'Categories',
}, },
}, },
}; };