|
18 | 18 | # ---------------------------------------------------------------------------------------
|
19 | 19 | # nginx_legacy_env() - Load global environment variables for configuring Nginx
|
20 | 20 | #
|
21 |
| -# @global NGINX_* The NGINX_ evnironment variables |
| 21 | +# @global NGINX_* The NGINX_ environment variables |
22 | 22 | # @return "export" statements which can be passed to eval()
|
23 | 23 | #
|
24 | 24 | nginx_legacy_env() {
|
|
146 | 146 | EOM
|
147 | 147 | fi
|
148 | 148 |
|
| 149 | + dynamicAccessLogDirective="" |
| 150 | + staticAccessLogDirective="" |
| 151 | + |
| 152 | + if is_boolean_yes "${NGINX_ACCESS_LOG_ENABLE}"; then |
| 153 | + if [ "${NGINX_ACCESS_LOG_FORMAT}" == "json" ]; then |
| 154 | + info "Nginx: Enabling access log using format 'json' ..." |
| 155 | + dynamicAccessLogDirective=" access_log ${FLOWNATIVE_LOG_PATH}/nginx-access.json.log main_json buffer=256k flush=5s;" |
| 156 | + else |
| 157 | + info "Nginx: Enabling access log using format 'default' ..." |
| 158 | + dynamicAccessLogDirective=" access_log ${FLOWNATIVE_LOG_PATH}/nginx-access.log main_ext buffer=256k flush=5s;" |
| 159 | + fi |
| 160 | + else |
| 161 | + info "Nginx: Access log is disabled" |
| 162 | + fi |
| 163 | + |
| 164 | + if [ "${NGINX_ACCESS_LOG_MODE}" == "all" ]; then |
| 165 | + info "Nginx: Enabling access log for all types of requests ..." |
| 166 | + staticAccessLogDirective=${dynamicAccessLogDirective} |
| 167 | + fi |
| 168 | + |
149 | 169 | cat >>"${NGINX_CONF_PATH}/sites-enabled/site.conf" <<-EOM
|
| 170 | +
|
| 171 | + $staticAccessLogDirective |
| 172 | +
|
150 | 173 | location ~ \\.php\$ {
|
151 | 174 | include fastcgi_params;
|
152 | 175 |
|
|
157 | 180 |
|
158 | 181 | fastcgi_pass ${BEACH_PHP_FPM_HOST}:${BEACH_PHP_FPM_PORT};
|
159 | 182 | fastcgi_index index.php;
|
| 183 | +
|
| 184 | + $dynamicAccessLogDirective |
160 | 185 | EOM
|
| 186 | + |
161 | 187 | if [ -n "${NGINX_CUSTOM_ERROR_PAGE_TARGET}" ]; then
|
162 | 188 | info "Nginx: Enabling custom error page pointing to ${BEACH_NGINX_CUSTOM_ERROR_PAGE_TARGET} ..."
|
163 | 189 | nginx_config_fastcgi_custom_error_page >>"${NGINX_CONF_PATH}/sites-enabled/site.conf"
|
|
219 | 245 | elif [ -n "${BEACH_PERSISTENT_RESOURCES_FALLBACK_BASE_URI}" ]; then
|
220 | 246 | cat >>"${NGINX_CONF_PATH}/sites-enabled/site.conf" <<-EOM
|
221 | 247 | location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}(.*)$" {
|
222 |
| - access_log off; |
| 248 | + ${staticAccessLogDirective} |
223 | 249 | expires ${NGINX_STATIC_FILES_LIFETIME};
|
224 | 250 | add_header Via '\$hostname' always;
|
225 | 251 | ${addHeaderStrictTransportSecurity}
|
|
237 | 263 | else
|
238 | 264 | cat >>"${NGINX_CONF_PATH}/sites-enabled/site.conf" <<-EOM
|
239 | 265 | location ~* ^/_Resources/Persistent/(.*)$ {
|
240 |
| - access_log off; |
| 266 | + ${staticAccessLogDirective} |
241 | 267 | expires ${NGINX_STATIC_FILES_LIFETIME};
|
242 | 268 | add_header Via '\$hostname' always;
|
243 | 269 | ${addHeaderStrictTransportSecurity}
|
|
256 | 282 | # for all static resources
|
257 | 283 | location ~ ^/_Resources/Static/ {
|
258 | 284 | add_header X-Static-Resource '\$hostname' always;
|
259 |
| - access_log off; |
| 285 | + ${staticAccessLogDirective} |
260 | 286 | expires ${NGINX_STATIC_FILES_LIFETIME};
|
261 | 287 | }
|
262 | 288 | }
|
|
0 commit comments