Viewing 8 replies - 1 through 8 (of 8 total)
  • This might interest you:

    /**
     * Get full file path to the server's config file for the site.
     *
     * Customize the returned value with the itsec_filter_server_config_file_path filter. Filter the value to a blank
     * string ("") in order to disable modifications to this file.
     *
     * @since 1.15.0
     *
     * @return string Full path to the server config file or a blank string if modifications for the file are disabled.
     */
    public static function get_server_config_file_path() {
    	$file = self::get_default_server_config_file_name();
    
    	if ( empty( $file ) ) {
    		return '';
    	}
    
    	$home_path = get_home_path();
    	$file_path = $home_path . $file;
    	$file_path = apply_filters( 'itsec_filter_server_config_file_path', $file_path, $file );
    
    	return $file_path;
    }
    
    /**
     * Get the default name for server config files based upon the web server.
     *
     * Customize the returned value with the itsec_filter_default_server_config_file_name filter. This filter can be
     * used to change the name of the config file used for this server, add support for additional server types (Apache
     * and nginx are supported by default), or to disable modifications for the active server type by returning a blank
     * string ("").
     *
     * @since 1.15.0
     * @access protected
     *
     * @return string|bool File name of the config file used for the server, a blank string if modifications for the
     *                     server config file are disabled, or a boolean false if the server is not recognized.
     */
    protected static function get_default_server_config_file_name() {
    	$server = ITSEC_Lib_Utility::get_web_server();
    
    	$defaults = array(
    		'apache'    => '.htaccess',
    		'litespeed' => '.htaccess',
    		'nginx'     => 'nginx.conf',
    	);
    
    	if ( isset( $defaults[$server] ) ) {
    		$name = $defaults[$server];
    	} else {
    		$name = false;
    	}
    
    	return apply_filters( 'itsec_filter_default_server_config_file_name', $name, $server );
    }

    dwinden

    Use the itsec_filter_server_config_file_path filter to customize the full file path to the server’s config file.

    Use the itsec_filter_default_server_config_file_name filter to customize the name of the server’s config file.

    If the above info helps you solve the issue please mark this topic as ‘resolved’.

    dwinden

    @tudoutou

    If the provided info helped you solve this issue please mark this topic as ‘resolved’.

    dwinden

    Thread Starter tudoutou

    (@tudoutou)

    @dvinden
    Thanks for the help!
    I might need to build an staging site to test the code.

    Thread Starter tudoutou

    (@tudoutou)

    Aha, the code above is source code, I thought it is something I need to put into functions.php

    Does that mean “NGINX Conf File” is useless?
    I’m asking because the description of this field is “The path on your server where backup files should be stored.
    This path must be writable by your website. For added security, it is recommended you do not include it in your website root folder.”

    It looks like iThemes Security want to set two fields:

    • NGINX Conf File
    • Path to Backup Files

    , but the function is still under development.

    Thread Starter tudoutou

    (@tudoutou)

    I modified the function to:

    /**
    	 * Get full file path to the server's config file for the site.
    	 *
    	 * Customize the returned value with the itsec_filter_server_config_file_path filter. Filter the value to a blank
    	 * string ("") in order to disable modifications to this file.
    	 *
    	 * @since 1.15.0
    	 *
    	 * @return string Full path to the server config file or a blank string if modifications for the file are disabled.
    	 */
    	public static function get_server_config_file_path() {
    		$file = self::get_default_server_config_file_name();
    
    		if ( empty( $file ) ) {
    			return '';
    		}
    
                    global $itsec_globals;
                    if ( empty( $itsec_globals['settings']['nginx_file'] ) ) {
                        $home_path = get_home_path();
                        $file_path = $home_path . $file;
                        $file_path = apply_filters( 'itsec_filter_server_config_file_path', $file_path, $file );
                    } else {
                        $file_path = $itsec_globals['settings']['nginx_file'];
                    }
    
    		return $file_path;
    	}

    It’s working now.

    Thread Starter tudoutou

    (@tudoutou)

    Thanks! dvinden

    @tudoutou

    Aha, the code above is source code, I thought it is something I need to put into functions.php

    Does that mean “NGINX Conf File” is useless?
    I’m asking because the description of this field is “The path on your server where backup files should be stored.
    This path must be writable by your website. For added security, it is recommended you do not include it in your website root folder.”

    Yes, it is source code from the class-itsec-lib-config-file.php file.
    It is part of new library classes for managing files, directories, and config files which were included as of the 4.8.0 (public) release.
    I think the idea of the filters is indeed to use them in the active theme functions.php file.

    There is a bug in the “NGINX Conf File” field description:

    Instead of:

    “The path on your server where backup files should be stored.”

    it should read something like this:

    “The name and path on your server of the NGINX configuration file.”

    Probably the developer copy\pasted code from a very similar field but forgot to properly change the field description…

    Anyway a new developer team has started with including new library classes for managing files, directories, and config files as of the 4.8.0 release. I could be wrong but I think they overlooked the “NGINX Conf File” setting. So it could very well be that the “NGINX Conf File” setting is rendered useless.

    dwinden

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘NGINX Conf file setting does not take effect’ is closed to new replies.