ubuntuusers.de

Nginx Wordpress vhost für subfolder

Status: Ungelöst | Ubuntu-Version: Server 17.10 (Artful Aardvark)
Antworten |

Nur-Ein-Blogger

Anmeldungsdatum:
4. April 2011

Beiträge: 146

Hallo, ich habe noch eine Frage bezüglich der nginx vhost.

Ich würde gern wordpress absichern. Die normale seite ist www.domain.de.

Nun soll aber Wordpress z.B. nach www.domain.de/wordpress installiert werden. Dazu gibt es eine var WORDPRESSPATHNAME die nur a-zA-Z enthalten kann.

Die vHost für den rootpfad wäre nachfolgendes script ohne /Variable also /${WORDPRESSPATHNAME}. Das klappt auch. Nun will ich aber gern die Fall sichern dass Wordpress eben in einem Subfolder ist. Dazu habe ich die vhost angepasst und wollte euch gern um Rat fragen ob das so eurer Meinung nach verträglich wäre und ist.

#Deny access to wp-content folders for suspicious files
location ~* ^/${WORDPRESSPATHNAME}/(wp-content)/(.*?)\.(zip|gz|tar|bzip2|7z)\$ { deny all; }
location ~ ^/${WORDPRESSPATHNAME}/wp-content/uploads/sucuri { deny all; }
location ~ ^/${WORDPRESSPATHNAME}/wp-content/updraft { deny all; }

# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
location ~*/${WORDPRESSPATHNAME} /(?:uploads|files)/.*\.php\$ { deny all; }

# Deny access to uploads that aren’t images, videos, music, etc.
location ~* ^/${WORDPRESSPATHNAME}/wp-content/uploads/.*.(html|htm|shtml|php|js|swf|css)$ {
    deny all;
}

# Block PHP files in content directory.
location ~* /${WORDPRESSPATHNAME}/wp-content/.*\.php\$ {
  deny all;
}
# Block PHP files in includes directory.
location ~* /${WORDPRESSPATHNAME}/wp-includes/.*\.php\$ {
  deny all;
}
# Block PHP files in uploads, content, and includes directory.
location ~* /${WORDPRESSPATHNAME}/(?:uploads|files|wp-content|wp-includes)/.*\.php\$ {
  deny all;
}
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
location ~* /${WORDPRESSPATHNAME} \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)\$|^(\..*|Entries.*|Repository|Root|Tag|Template)\$|\.php_
{
return 444;
}
#nocgi
location ~* /${WORDPRESSPATHNAME} \.(pl|cgi|py|sh|lua)\$ {
return 444;
}
#disallow
location ~* /${WORDPRESSPATHNAME} (w00tw00t) {
return 444;
}
location ~* /${WORDPRESSPATHNAME} /(\.|wp-config\.php|wp-config\.txt|changelog\.txt|readme\.txt|readme\.html|license\.txt) { deny all; }

# Hide sensitive files
location ~* /${WORDPRESSPATHNAME} .(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$|^(..*|Entries.*|Repository|Root|Tag|Template)$|.php_
{
        return 444;
}

# Stop image hotlinking
location ~ /${WORDPRESSPATHNAME} .(gif|png|jpe?g)$ {
     valid_referers none blocked ${MYDOMAIN} *.${MYDOMAIN};
     if ($invalid_referer) {
        return   403;
    }
}
Antworten |