How to move the Fleio installation to a new URL

You have already installed Fleio and you want to change the URL, maybe for adding an SSL certificate. Here’s how to do it.

The following steps have been tested on an Ubuntu 18.04 install, so let’s assume that you have filled 12.34.56.78 address when running the bootstrap:

* Install Fleio at URL [http://12.34.56.78]:

and you are logged in as root.

So URL http://12.34.56.78 was filled in all the settings and you want to change the URL to http://mydomain.com.

1. Change the nginx config file name

cd /etc/nginx/sites-enabled/
mv 12.34.56.78.conf mydomain.com.conf

2. Change server name in nginx config

Edit the nginx conf file:

vi mydomain.com.conf
# change the server_name 12.34.56.67; directive to:
server_name mydomain.com;

Save, exit the editor, then restart the nginx service:

systemctl restart nginx

3. Change allowed hosts and frontend URL in Fleio settings.py

# edit backend settings
vi /var/webapps/fleio/project/fleio/fleiosettings/settings.py
# change ALLOWED_HOSTS. You can also have a list of domains if needed:
ALLOWED_HOSTS = ['mydomain.com']
# change FRONTEND_URL. You can use https:// if you have a SSL ceritificate
FRONTEND_URL = 'http://mydomain.com'

Trailing slash is not required and it won’t affect Fleio functionality if it’s added or not.

Optionally, if you have the Fleio frontend on another domain or if you have multiple frontends, each with another domain, you must also uncomment these lines in settings.py and add all the domains to CORS_ORIGIN_WHITELIST:

# NEW_MIDDLEWARE = list(MIDDLEWARE)
# NEW_MIDDLEWARE.insert(1, 'corsheaders.middleware.CorsMiddleware')
# MIDDLEWARE = tuple(NEW_MIDDLEWARE)
# CORS_ORIGIN_WHITELIST = (
#    'http://host1',
#    'http://host2',
# )
# CORS_ALLOW_CREDENTIALS = True

Note that since django-cors-headers version 3.0.0 you need to specify an URI scheme for each origin.

WARNING: Fleio only works if both the backend and the frontend are on the same domain or on different subdomains of the same domain.

If the backend and the frontend are on different subdomains, you need to add this to settings.py:

CSRF_COOKIE_DOMAIN = '.mydomain.com'

This ensures that cookies are accessible by all subdomains of mydomain.com.

If you have multiple frontends on a single Fleio backend, also edit this section from settings.py:

FRONTEND_URL = 'http://mydomain.com'

# The mapping consists of key-value pairs where the key stands for the client_group and the value will be its
# corresponding frontend URL; each client account will be associated with a group or multiple groups through ClientGroup
# For two frontend urls using the same backend the setting will look like:
# FRONTEND_URL_MAPPING = {'client_group1' : 'http://urlexample1.com/', 'client_group2': 'http://urlexample2.com/'}

Save, exit the editor, then restart fleio services:

systemctl restart uwsgi
systemctl restart fleio
systemctl restart celery

4. Change backend API URL in frontend settings

Edit end-user panel settings:

vi /var/webapps/fleio/frontend/site/constants/constants.js

and change api_url: 'http://12.34.56.78/backend/api' to

api_url: 'http://mydomain.com/backend/api'

and the same thing for the staff panel:

vi /var/webapps/fleio/frontend/site/staff/constants/constants.js

change api_url: 'http://12.34.56.78/backend/staffapi' to

api_url: 'http://mydomain.com/backend/staffapi',

Your Fleio installation should now work on the new domain.