ServerRoot "/usr/pkg" Listen 0.0.0.0:80 #LoadModule mpm_event_module lib/httpd/mod_mpm_event.so LoadModule mpm_prefork_module lib/httpd/mod_mpm_prefork.so #LoadModule mpm_worker_module lib/httpd/mod_mpm_worker.so LoadModule authn_file_module lib/httpd/mod_authn_file.so #LoadModule authn_dbm_module lib/httpd/mod_authn_dbm.so #LoadModule authn_anon_module lib/httpd/mod_authn_anon.so #LoadModule authn_dbd_module lib/httpd/mod_authn_dbd.so #LoadModule authn_socache_module lib/httpd/mod_authn_socache.so LoadModule authn_core_module lib/httpd/mod_authn_core.so LoadModule authz_host_module lib/httpd/mod_authz_host.so LoadModule authz_groupfile_module lib/httpd/mod_authz_groupfile.so LoadModule authz_user_module lib/httpd/mod_authz_user.so #LoadModule authz_dbm_module lib/httpd/mod_authz_dbm.so #LoadModule authz_owner_module lib/httpd/mod_authz_owner.so #LoadModule authz_dbd_module lib/httpd/mod_authz_dbd.so LoadModule authz_core_module lib/httpd/mod_authz_core.so LoadModule access_compat_module lib/httpd/mod_access_compat.so LoadModule auth_basic_module lib/httpd/mod_auth_basic.so #LoadModule auth_form_module lib/httpd/mod_auth_form.so #LoadModule auth_digest_module lib/httpd/mod_auth_digest.so #LoadModule allowmethods_module lib/httpd/mod_allowmethods.so #LoadModule file_cache_module lib/httpd/mod_file_cache.so #LoadModule cache_module lib/httpd/mod_cache.so #LoadModule cache_disk_module lib/httpd/mod_cache_disk.so #LoadModule cache_socache_module lib/httpd/mod_cache_socache.so #LoadModule socache_shmcb_module lib/httpd/mod_socache_shmcb.so #LoadModule socache_dbm_module lib/httpd/mod_socache_dbm.so #LoadModule socache_memcache_module lib/httpd/mod_socache_memcache.so #LoadModule socache_redis_module lib/httpd/mod_socache_redis.so #LoadModule watchdog_module lib/httpd/mod_watchdog.so #LoadModule macro_module lib/httpd/mod_macro.so #LoadModule dbd_module lib/httpd/mod_dbd.so #LoadModule dumpio_module lib/httpd/mod_dumpio.so #LoadModule echo_module lib/httpd/mod_echo.so #LoadModule buffer_module lib/httpd/mod_buffer.so #LoadModule data_module lib/httpd/mod_data.so #LoadModule ratelimit_module lib/httpd/mod_ratelimit.so LoadModule reqtimeout_module lib/httpd/mod_reqtimeout.so #LoadModule ext_filter_module lib/httpd/mod_ext_filter.so #LoadModule request_module lib/httpd/mod_request.so #LoadModule include_module lib/httpd/mod_include.so LoadModule filter_module lib/httpd/mod_filter.so #LoadModule reflector_module lib/httpd/mod_reflector.so #LoadModule substitute_module lib/httpd/mod_substitute.so #LoadModule sed_module lib/httpd/mod_sed.so #LoadModule charset_lite_module lib/httpd/mod_charset_lite.so #LoadModule deflate_module lib/httpd/mod_deflate.so #LoadModule xml2enc_module lib/httpd/mod_xml2enc.so #LoadModule proxy_html_module lib/httpd/mod_proxy_html.so #LoadModule brotli_module lib/httpd/mod_brotli.so LoadModule mime_module lib/httpd/mod_mime.so LoadModule log_config_module lib/httpd/mod_log_config.so #LoadModule log_debug_module lib/httpd/mod_log_debug.so #LoadModule log_forensic_module lib/httpd/mod_log_forensic.so #LoadModule logio_module lib/httpd/mod_logio.so LoadModule env_module lib/httpd/mod_env.so #LoadModule mime_magic_module lib/httpd/mod_mime_magic.so #LoadModule expires_module lib/httpd/mod_expires.so LoadModule headers_module lib/httpd/mod_headers.so #LoadModule usertrack_module lib/httpd/mod_usertrack.so #LoadModule unique_id_module lib/httpd/mod_unique_id.so LoadModule setenvif_module lib/httpd/mod_setenvif.so LoadModule version_module lib/httpd/mod_version.so #LoadModule remoteip_module lib/httpd/mod_remoteip.so #LoadModule proxy_module lib/httpd/mod_proxy.so #LoadModule proxy_connect_module lib/httpd/mod_proxy_connect.so #LoadModule proxy_ftp_module lib/httpd/mod_proxy_ftp.so #LoadModule proxy_http_module lib/httpd/mod_proxy_http.so #LoadModule proxy_fcgi_module lib/httpd/mod_proxy_fcgi.so #LoadModule proxy_scgi_module lib/httpd/mod_proxy_scgi.so #LoadModule proxy_uwsgi_module lib/httpd/mod_proxy_uwsgi.so #LoadModule proxy_fdpass_module lib/httpd/mod_proxy_fdpass.so #LoadModule proxy_wstunnel_module lib/httpd/mod_proxy_wstunnel.so #LoadModule proxy_ajp_module lib/httpd/mod_proxy_ajp.so #LoadModule proxy_balancer_module lib/httpd/mod_proxy_balancer.so #LoadModule proxy_express_module lib/httpd/mod_proxy_express.so #LoadModule proxy_hcheck_module lib/httpd/mod_proxy_hcheck.so #LoadModule session_module lib/httpd/mod_session.so #LoadModule session_cookie_module lib/httpd/mod_session_cookie.so #LoadModule session_dbd_module lib/httpd/mod_session_dbd.so #LoadModule slotmem_shm_module lib/httpd/mod_slotmem_shm.so #LoadModule slotmem_plain_module lib/httpd/mod_slotmem_plain.so #LoadModule ssl_module lib/httpd/mod_ssl.so #LoadModule dialup_module lib/httpd/mod_dialup.so #LoadModule http2_module lib/httpd/mod_http2.so #LoadModule lbmethod_byrequests_module lib/httpd/mod_lbmethod_byrequests.so #LoadModule lbmethod_bytraffic_module lib/httpd/mod_lbmethod_bytraffic.so #LoadModule lbmethod_bybusyness_module lib/httpd/mod_lbmethod_bybusyness.so #LoadModule lbmethod_heartbeat_module lib/httpd/mod_lbmethod_heartbeat.so LoadModule unixd_module lib/httpd/mod_unixd.so #LoadModule heartbeat_module lib/httpd/mod_heartbeat.so #LoadModule heartmonitor_module lib/httpd/mod_heartmonitor.so #LoadModule dav_module lib/httpd/mod_dav.so LoadModule status_module lib/httpd/mod_status.so LoadModule autoindex_module lib/httpd/mod_autoindex.so #LoadModule asis_module lib/httpd/mod_asis.so #LoadModule info_module lib/httpd/mod_info.so LoadModule cgid_module lib/httpd/mod_cgid.so #LoadModule dav_fs_module lib/httpd/mod_dav_fs.so #LoadModule dav_lock_module lib/httpd/mod_dav_lock.so #LoadModule vhost_alias_module lib/httpd/mod_vhost_alias.so #LoadModule negotiation_module lib/httpd/mod_negotiation.so LoadModule dir_module lib/httpd/mod_dir.so #LoadModule actions_module lib/httpd/mod_actions.so #LoadModule speling_module lib/httpd/mod_speling.so LoadModule userdir_module lib/httpd/mod_userdir.so LoadModule alias_module lib/httpd/mod_alias.so LoadModule rewrite_module lib/httpd/mod_rewrite.so LoadModule perl_module lib/httpd/mod_perl.so LoadModule php7_module lib/httpd/mod_php7.so User www Group www # # rbsd.ankarstrom.se # ServerName rbsd.ankarstrom.se:80 ServerAdmin john@ankarstrom.se DocumentRoot "/var/www/rbsd/htdocs" # Secure root filesystem AllowOverride none Require all denied Options Indexes FollowSymLinks AllowOverride All Require all granted DirectoryIndex index.php index.html Require all denied ErrorLog "/var/log/httpd/error_log" LogLevel warn LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "/var/log/httpd/access_log" combined # Put Redirect, Alias and ScriptAlias directives here ScriptAlias /cgi-bin/ "/usr/pkg/libexec/cgi-bin/" AllowOverride None Options None Require all granted # # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied # backend servers which have lingering "httpoxy" defects. # 'Proxy' request header is undefined by the IETF, not listed by IANA # RequestHeader unset Proxy early TypesConfig etc/httpd/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz #AddType application/x-gzip .tgz #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz #AddHandler cgi-script .cgi #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml SetHandler application/x-httpd-php #MIMEMagicFile etc/httpd/magic # Server-pool management (MPM specific) #Include etc/httpd/httpd-mpm.conf # Multi-language error messages #Include etc/httpd/httpd-multilang-errordoc.conf # Fancy directory listings #Include etc/httpd/httpd-autoindex.conf # Language settings #Include etc/httpd/httpd-languages.conf # User home directories Include etc/httpd/httpd-userdir.conf # Real-time info on requests and configuration #Include etc/httpd/httpd-info.conf # Virtual hosts #Include etc/httpd/httpd-vhosts.conf # Local access to the Apache HTTP Server Manual #Include etc/httpd/httpd-manual.conf # Distributed authoring and versioning (WebDAV) #Include etc/httpd/httpd-dav.conf # Various default settings #Include etc/httpd/httpd-default.conf # Configure mod_proxy_html to understand HTML4/XHTML1 Include etc/httpd/proxy-html.conf # Secure (SSL/TLS) connections #Include etc/httpd/httpd-ssl.conf # # Note: The following must must be present to support # starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl. # SSLRandomSeed startup builtin SSLRandomSeed connect builtin use warnings; use subs qw/vhost idn with_idn block/; use Tie::DxHash; # Long-term redirections my %redir = ( 'git.ankarstrom.se' => block( RewriteRule => '^vix/?$ /exrc/ [L,R,END]', RewriteRule => '^vix/?$ /exrc/ [L,R,END]', RewriteRule => '^kq-watch/?$ /when/ [L,R,END]', RewriteRule => '^x11/([^/]*)/?$ /$1/ [L,R,END]', RewriteRule => '^cpan/([^/]*)/?$ /$1/ [L,R,END]', RewriteRule => '^cfg/([^/]*)/?$ /$1/ [L,R,END]', RewriteRule => '^([^/]*)\.git(/.*)?$ /$1$2 [L,R,END]', ), 'john.ankarstrom.se' => block( Redirect => '301 /feed.rss /articles.xml', Redirect => '301 /feed.php /articles.xml', Redirect => '301 /english/texts/replacing-javascript /replacing-javascript', Redirect => '301 /web/separation-of-concerns.html /separation-of-concerns', Redirect => '301 /unix/learning-c.html /learning-c', Redirect => '301 /scripts http://git.ankarstrom.se/', Redirect => '301 /software http://git.ankarstrom.se', Redirect => '301 /ansi-sv-layout /sv-ansi', ), 'software.ankarstrom.se' => block( RewriteRule => '^(win32/)?ahk(/.*)? http://git.ankarstrom.se/ahk/about/ [L,R]', RewriteRule => '^(win32/)?drm(/.*)? http://git.ankarstrom.se/drm/about/ [L,R]', RewriteRule => '^(win32/)?run(/.*)? http://git.ankarstrom.se/run/about/ [L,R]', RewriteRule => '^(win32/)?tt(/.*)? http://git.ankarstrom.se/tt/about/ [L,R]', RewriteRule => '^(win32/)?watch(/.*)? http://git.ankarstrom.se/watch/about/ [L,R]', RewriteRule => '^.* http://git.ankarstrom.se/ [L,R]', ), ); # Virtual host configuration vhost block(ServerName => 'ankarstrom.se', ServerAlias => [with_idn 'www.ankarstrom.se'], DocumentRoot => '/var/www/rbsd/htdocs', ); vhost block(ServerName => 'lamnafacebook.nu', DocumentRoot => '/var/www/facebook/htdocs', ServerAlias => [with_idn 'www.lamnafacebook.nu'], ); vhost block(ServerName => 'git.ankarstrom.se', Directory => block('/var/www/git/htdocs' => block( DirectoryIndex => 'cgit.cgi', Options => '+ExecCGI', AddHandler => 'cgi-script .cgi', RewriteEngine => 'On', %{$redir{'git.ankarstrom.se'}}, RewriteCond => '%{REQUEST_FILENAME} !-f', RewriteCond => '%{REQUEST_FILENAME} !-d', RewriteRule => '(.*) cgit.cgi/$1 [END,QSA]', )), ); vhost block(ServerName => 'dev.ankarstrom.se'); vhost block(ServerName => 'img.ankarstrom.se'); vhost block(ServerName => 'john.ankarstrom.se'); vhost block(ServerName => 'mail.ankarstrom.se'); vhost block(ServerName => 'software.ankarstrom.se'); vhost block(ServerName => 'perlisdead.org', DocumentRoot => '/var/www/perlisdead/out' ); # Default virtual host configuration sub vhost { my $vhost = $_[0]; # this should be a hash ref tied to Tie::DxHash if (!$vhost->{ServerName}) { warn 'Call to vhost missing ServerName, skipping virtual host'; return; } # Merge directives of which only one instance is allowed if (!$vhost->{DocumentRoot}) { (my $subdomain = $vhost->{ServerName}) =~ s/\..*//; $vhost->{DocumentRoot} = "/var/www/$subdomain/htdocs"; } # Merge directives of which multiple instances are allowed my $default = block( ServerAlias => idn($vhost->{ServerName}), Directory => block( $vhost->{DocumentRoot} => block( Options => 'Indexes FollowSymLinks', AllowOverride => 'All', Require => 'all granted', exists $redir{$vhost->{ServerName}} ? (RewriteEngine => 'On') : (), %{$redir{$vhost->{ServerName}}}, ), ), ); my @keys = keys %$vhost; my @values = values %$vhost; for (my $i = 0; $i < @keys; $i++) { $default->{$keys[$i]} = $values[$i]; } $vhost = $default; $VirtualHost{'*:80'} = [@{$VirtualHost{'*:80'}||[]}, $vhost]; } sub idn { my ($domain) = @_; $domain =~ s/ankarstrom\.se$/xn--ankarstrm-77a.se/; $domain =~ s/lamnafacebook\.nu$/xn--lmnafacebook-gcb.nu/; return $domain; } sub with_idn { return $_[0], idn $_[0]; } sub block { my %hash; tie %hash, 'Tie::DxHash'; %hash = @_; return \%hash; }