mirror of
				https://github.com/digitalocean/nginxconfig.io.git
				synced 2025-11-04 09:26:11 +08:00 
			
		
		
		
	More confs!
This commit is contained in:
		@@ -35,19 +35,19 @@ export default () => {
 | 
			
		||||
    config['location ^~ /media/'] = {
 | 
			
		||||
        try_files: '$uri $uri/ /get.php?$args',
 | 
			
		||||
 | 
			
		||||
        'location ~* .(?:ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$': {
 | 
			
		||||
        'location ~* \\.(?:ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$': {
 | 
			
		||||
            expires: '+1y',
 | 
			
		||||
            add_header: 'Cache-Control "public"',
 | 
			
		||||
            try_files: '$uri $uri/ /get.php?$args',
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        'location ~* .(?:zip|gz|gzip|bz2|csv|xml)$': {
 | 
			
		||||
        'location ~* \\.(?:zip|gz|gzip|bz2|csv|xml)$': {
 | 
			
		||||
            expires: 'off',
 | 
			
		||||
            add_header: 'Cache-Control "no-store"',
 | 
			
		||||
            try_files: '$uri $uri/ /get.php?$args',
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        'location ~ ^/media/theme_customization/.*.xml': {
 | 
			
		||||
        'location ~ ^/media/theme_customization/.*\\.xml': {
 | 
			
		||||
            deny: 'all',
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
@@ -56,9 +56,33 @@ export default () => {
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // TODO: static route
 | 
			
		||||
    // TODO: static files
 | 
			
		||||
    // TODO: deny cron
 | 
			
		||||
    config['# Magento: static route'] = '';
 | 
			
		||||
    config['location @magento_static'] = {
 | 
			
		||||
        rewrite: '^/static/(version\\d*/)?(.*)$ /static.php?resource=$2 last',
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    config['# Magento: static files'] = '';
 | 
			
		||||
    config['location ^~ /static/'] = {
 | 
			
		||||
        expires: 'max',
 | 
			
		||||
        try_files: '$uri $uri/ @magento_static',
 | 
			
		||||
 | 
			
		||||
        'location ~* \\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$': {
 | 
			
		||||
            expires: '+1y',
 | 
			
		||||
            add_header: 'Cache-Control "public"',
 | 
			
		||||
            try_files: '$uri $uri/ magento_static',
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        'location ~* .(zip|gz|gzip|bz2|csv|xml)$': {
 | 
			
		||||
            expires: 'off',
 | 
			
		||||
            add_header: 'Cache-Control "no-store"',
 | 
			
		||||
            try_files: '$uri $uri/ @magento_static',
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    config['# Magento: deny cron'] = '';
 | 
			
		||||
    config['location ~ cron\\.php'] = {
 | 
			
		||||
        deny: 'all',
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // Done!
 | 
			
		||||
    return config;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								src/nginxconfig/generators/php_fastcgi.conf.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/nginxconfig/generators/php_fastcgi.conf.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
export default (domains, global) => {
 | 
			
		||||
    const legacyRouting = domains.some(d => d.routing.legacyPhpRouting.computed);
 | 
			
		||||
    const config = {};
 | 
			
		||||
 | 
			
		||||
    if (legacyRouting) {
 | 
			
		||||
        config['# split path'] = '';
 | 
			
		||||
        config.fastcgi_split_path_info = '^(.+\\.php)(/.+)$';
 | 
			
		||||
        config.set = '$_fastcgi_path_info $fastcgi_path_info';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    config['# 404'] = '';
 | 
			
		||||
    config.try_files = '$fastcgi_script_name =404';
 | 
			
		||||
 | 
			
		||||
    config['# default fastcgi_params'] = '';
 | 
			
		||||
    config.include = 'fastcgi_params';
 | 
			
		||||
 | 
			
		||||
    config['# fastcgi settings'] = '';
 | 
			
		||||
    config.fastcgi_pass = domains.some(d => d.php.php.computed) && global.php.phpBackupServer
 | 
			
		||||
        ? 'php'
 | 
			
		||||
        : ((global.php.phpServer.computed[0] === '/' ? 'unix:' : '') + global.php.phpServer.computed);
 | 
			
		||||
    config.fastcgi_index = 'index.php';
 | 
			
		||||
    config.fastcgi_buffers = '8 16k';
 | 
			
		||||
    config.fastcgi_buffer_size = '32k';
 | 
			
		||||
 | 
			
		||||
    config['# fastcgi params'] = '';
 | 
			
		||||
    config['fastcgi_param DOCUMENT_ROOT'] = '$realpath_root';
 | 
			
		||||
    config['fastcgi_param SCRIPT_FILENAME'] = '$realpath_root$fastcgi_script_name';
 | 
			
		||||
    if (legacyRouting) config['fastcgi_param PATH_INFO'] = '$_fastcgi_path_info';
 | 
			
		||||
    config['fastcgi_param PHP_ADMIN_VALUE'] = '"open_basedir=$base/:/usr/lib/php/:/tmp/"';
 | 
			
		||||
 | 
			
		||||
    // Done!
 | 
			
		||||
    return config;
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user