Skip to content

Instantly share code, notes, and snippets.

@deanet
Forked from anonymous/gist:5814858
Last active December 18, 2015 16:58
Show Gist options
  • Save deanet/5814901 to your computer and use it in GitHub Desktop.
Save deanet/5814901 to your computer and use it in GitHub Desktop.
#example vhost protect wp-login.php at nginx php-fpm
upstream arraudhah {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name ar-raudhah.info www.ar-raudhah.info;
server_name_in_redirect off;
access_log /srv/htdocs/arraudhah/logs/arraudhah.access_log;
error_log /srv/htdocs/arraudhah/logs/arraudhah.error_log info;
root /srv/htdocs/arraudhah/http/;
index index.php index.html index.htm default.html default.htm;
location / {
##permalinks
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /unduh {
rewrite ^/unduh/([^/]+)$ http://www.ar-raudhah.info/wp-content/plugins/download-monitor/download.php?id=$1 redirect;
}
location ~* /wp-login.php {
auth_basic "Pejuang Ar-Raudhah Area";
auth_basic_user_file /path/passwd;
location ~ \.php$ {
fastcgi_pass arraudhah;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
location ~ \.php$ {
fastcgi_pass arraudhah;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
"mod_accesslog",
"mod_auth"
)
server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
#### accesslog format (enable for using a proxy, like Pound, in front of Lighttpd)
# accesslog.format = "%{X-Forwarded-For}i %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
#### accesslog module
accesslog.filename = "/var/log/lighttpd/access.log"
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
$HTTP["host"] =~ "www.sarkub.com" {
url.rewrite-final = (
# Exclude some directories from rewriting
"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
# Exclude .php files at root from rewriting
"^/(.*.php)" => "$0",
# Handle permalinks and feeds
"^/(.*)$" => "/index.php/$1"
)
$HTTP["url"] =~ "^\/wp-admin\/.*" {
$HTTP["url"] !~ "^\/wp-admin\/(admin-ajax\.php|css\/.*)" {
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/path/passwd"
auth.require = (
"" => (
"method" => "basic",
"realm" => "Password protected area",
"require" => "valid-user",
),
),
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment