diff --git a/core/app.cpp b/core/app.cpp index 0c48f48..51590fe 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -175,13 +175,14 @@ void App::Close() bool App::BaseUrlRedirect() { - if( config.base_url_http_host.empty() ) + if( config.base_url.empty() ) return false; - if( Equal(config.base_url_http_host.c_str(), cur.request->env_http_host) ) + if( Equal(config.base_url.c_str(), cur.request->env_http_host) ) return false; - cur.request->redirect_to = config.base_url; + system.PutUrlProto(config.use_ssl, cur.request->redirect_to); + cur.request->redirect_to += config.base_url; AssignString(cur.request->env_request_uri, cur.request->redirect_to, false); // cur.request->env_request_uri should not be UrlEncoded cur.request->redirect_url_encoded = true; @@ -1164,7 +1165,10 @@ sigset_t set; app->Lock(); app->synchro.was_stop_signal = true; FCGX_ShutdownPending(); - Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit); + + // here we don't have to use SSL version so we always use config.url_proto + Ezc::WideToUTF8(app->config.url_proto, app->url_to_fetch_on_exit); + Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit, false); app->Unlock(); // this thread will hang on this method diff --git a/core/config.cpp b/core/config.cpp index 458e952..9443c43 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -144,12 +144,18 @@ void Config::AssignValues(bool stdout_is_closed) db_pass = AText(L"db_pass"); item_url_empty = Text(L"item_url_empty"); - base_server = Text(L"base_server"); + url_proto = Text(L"url_proto", L"http://"); + url_ssl_proto = Text(L"url_ssl_proto", L"https://"); + + use_ssl = Bool(L"use_ssl", false); + use_ssl_static = Bool(L"use_ssl_static", false); + use_ssl_common = Bool(L"use_ssl_common", false); + use_ssl_only_for_logged_users = Bool(L"use_ssl_only_for_logged_users", true); + base_url = Text(L"base_url"); base_url_static = Text(L"base_url_static"); base_url_common = Text(L"base_url_common"); - NoLastSlash(base_server); NoLastSlash(base_url); NoLastSlash(base_url_static); NoLastSlash(base_url_common); @@ -218,8 +224,6 @@ void Config::AssignValues(bool stdout_is_closed) void Config::SetAdditionalVariables() { - SetHttpHost(base_url, base_url_http_host); - if( html_filter_orphans_mode_str == "160" ) html_filter_orphans_mode = HTMLFilter::orphan_160space; else @@ -283,21 +287,6 @@ void Config::CheckPasswd() } -void Config::SetHttpHost(const std::wstring & in, std::wstring & out) -{ - const char http[] = "http://"; - const char https[] = "https://"; - size_t http_len = sizeof(http) / sizeof(char) - 1; - size_t https_len = sizeof(https) / sizeof(char) - 1; - - if( IsSubString(http, in.c_str()) ) - out = in.substr(http_len); - else - if( IsSubString(https, in.c_str()) ) - out = in.substr(https_len); - else - out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done -} std::wstring Config::Text(const wchar_t * name) diff --git a/core/config.h b/core/config.h index 79dcaaa..e9ea994 100755 --- a/core/config.h +++ b/core/config.h @@ -119,11 +119,6 @@ public: std::string http_session_id_name; - // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) - // the server will redirect into 'base_url' + 'REQUEST_URI' - // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. - bool base_url_redirect; - // string used in a place where is a user (or group) selected std::wstring priv_no_user; std::wstring priv_no_group; @@ -286,16 +281,48 @@ public: // not available in config -- set automatically based on locale_default size_t locale_default_index; - // the main address of the server (e.g. someserver.com) (without the 'www' part etc) - std::wstring base_server; - // the main address of the site (e.g. http://www.someserver.com) + // url protocol + // default: http:// + std::wstring url_proto; + + // url protocol when using SSL + // default: https:// + std::wstring url_ssl_proto; + + // enables SSL + // this is related to [doc_base_url] ezc function + // default: false + bool use_ssl; + + // enables SSL with [doc_base_url_static] + // default: false + bool use_ssl_static; + + // enables SSL with [doc_base_url_common] + // default: false + bool use_ssl_common; + + // if SSL is enabled then if this is true the SSL will be used + // only for logged users + // default: true + bool use_ssl_only_for_logged_users; + + // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) + // the server will redirect into 'base_url' + 'REQUEST_URI' + // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. + bool base_url_redirect; + + // the main address of the site (e.g. www.someserver.com) + // (without http:// prefix) std::wstring base_url; // static content not authorized by winix + // (e.g. static.someserver.com) std::wstring base_url_static; // additional static server for common content (not authorized) + // (e.g. common.someserver.com) std::wstring base_url_common; // separator used in