From 10b245399d63a4191cec59a4e1b084b8f277f30b Mon Sep 17 00:00:00 2001 From: daN4cat Date: Sat, 2 Sep 2023 18:18:32 +0100 Subject: [PATCH] Revert config.php changes --- README.md | 2 ++ application/config/config.php | 6 ++++-- docker-compose.nginx.yml | 1 + docker-compose.yml | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c22c8fa48..c49a76a60 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,8 @@ NOTE: If you're running non-release code, please make sure you always run the la - If the avatar pictures are not shown in items or at item save you get an error, please make sure your `public` and subdirs are assigned to the correct owner and the access permission is set to `750`. +- If you install OSPOS in Docker behind a proxy that performs `ssloffloading`, you can enable the URL generated to be HTTPS instead of HTTP, by activating the environment variable `FORCE_HTTPS = 1`. + - If you install OSPOS behind a proxy and OSPOS constantly drops your session, consider whitelisting the proxy IP address by setting `$config['proxy_ips'] = '';` in the [main php config file](https://github.com/opensourcepos/opensourcepos/blob/master/application/config/config.php). In extreme instances, changing `$config['sess_match_ip'] = TRUE;` to `FALSE` may also help. - If you have suhosin installed and face an issue with CSRF, please make sure you read [issue #1492](https://github.com/opensourcepos/opensourcepos/issues/1492). diff --git a/application/config/config.php b/application/config/config.php index a9077bb48..e2bfb5ee8 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -65,7 +65,9 @@ $config['db_log_enabled'] = FALSE; | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = '//' . ((isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : 'localhost') ; +$config['https_on'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_ENV['FORCE_HTTPS']) && $_ENV['FORCE_HTTPS'] == 'true'); +$config['base_url'] = $config['https_on'] ? 'https' : 'http'; +$config['base_url'] .= '://' . ((isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : 'localhost') ; $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); /* @@ -436,7 +438,7 @@ $config['sess_regenerate_destroy'] = FALSE; $config['cookie_prefix'] = ''; $config['cookie_domain'] = ''; $config['cookie_path'] = '/'; -$config['cookie_secure'] = TRUE; +$config['cookie_secure'] = $config['https_on']; $config['cookie_httponly'] = TRUE; /* diff --git a/docker-compose.nginx.yml b/docker-compose.nginx.yml index eff5f6266..6653cb0cf 100644 --- a/docker-compose.nginx.yml +++ b/docker-compose.nginx.yml @@ -28,6 +28,7 @@ services: - logs:/app/application/logs environment: - CI_ENV=${OSPOS_CI_ENV} + - FORCE_HTTPS=true - PHP_TIMEZONE=UTC - MYSQL_USERNAME=${OSPOS_MYSQL_USERNAME} - MYSQL_PASSWORD=${OSPOS_MYSQL_PASSWORD} diff --git a/docker-compose.yml b/docker-compose.yml index b74bd198d..76909bbf2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,7 @@ services: - logs:/app/application/logs environment: - CI_ENV=production + - FORCE_HTTPS=false - PHP_TIMEZONE=UTC - MYSQL_USERNAME=admin - MYSQL_PASSWORD=pointofsale