Má všeobecná wiki

Kdo je blbý, ať si kůpi notes, já mám tuto wiki...

Uživatelské nástroje

Nástroje pro tento web


banana_pi_m2u:lighttpd:konfigurace_vhostu

Konfigurace vhostů

Tyto konfigurace dáváme do /etc/lighttpd/sites-available/ a zapínáme symlinkem ze sites-available do sites-enabled/jmeno.conf.

default.conf

Základní stránka pro statický web bez PHP.

default.conf
# Default vhost
$HTTP["host"] == "site.example.com" {

        server.document-root = "/var/www/html"

        include "snippets/example.com-certs.conf"
        include "snippets/http-to-https.conf"
}

php.conf

Stránka pro weby v PHP.

php.conf
# PHP vhost

$HTTP["host"] == "php.example.com" {

    server.document-root = "/var/www/php"
        index-file.names = ("index.php", "index.html")

        include "snippets/example.com-certs.conf"
        include "snippets/http-to-https.conf"


        ## Start an FastCGI server for php (needs the php5-cgi package)
        fastcgi.server += ( ".php" =>
                ((
                        "bin-path" => "/usr/bin/php-cgi",
                        "socket" => "/var/run/lighttpd/php.socket",
                        "max-procs" => 1,
                        "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "4",
                        "PHP_FCGI_MAX_REQUESTS" => "10000"
                ),
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                ),
                        "broken-scriptfilename" => "enable"
                ))
        )
}

perl.conf

Pro stránky v PERLu..

perl.conf
# Perl vhost

$HTTP["host"] == "perl.example.com" {

        server.document-root = "/var/www/perl"
        alias.url = ( "/cgi" => "/var/www/perl/cgi/" )

        $HTTP["url"] =~ "^/cgi/" {
                cgi.assign = (".cgi" => "/usr/bin/perl")
        }

        include "snippets/example.com-certs.conf"
        include "snippets/http-to-https.conf"
}

c.conf

Pro stránky v C.

c.conf
# C vhost

$HTTP["host"] == "c.example.com" {

        server.document-root = "/var/www/c"
        index-file.names = ("index.c") #Nahradit jménem spustitelné binárky

        $HTTP["url"] =~ "/" {
                cgi.assign = (".c" => "")
        }


        include "snippets/example.com-certs.conf"
        include "snippets/http-to-https.conf"
}

ruby.conf

ruby.conf
# Ruby vhost

$HTTP["host"] == "ruby.example.com" {

        server.document-root = "/var/www/ruby"

        cgi.assign = (
                ".rb"  => "/usr/bin/ruby",
                ".erb" => "/usr/bin/eruby",
        )

        include "snippets/example.com-certs.conf"
        include "snippets/http-to-https.conf"
}

gitea.conf

Toto bylo trošičku složitější kvůli trablím s aliasem, který se gitea rozhodla ignorovat. Není to tak elegantní ale funguje to. Aneb když nešel Mohamed k hoře, šla hora k Mohamedovi.

gitea.conf
# Gitea vhost

$HTTP["host"] == "git.example.com" {

        include "snippets/example.com-certs.conf"

        $HTTP["scheme"] == "http" {
        # but not the letsencrypt webroot ...
                $HTTP["url"] =~ "^/\.well-known" {
                        alias.url += (
                                "/.well-known/" => "/var/www/dehydrated/.well-known/"
                        )
                }
                # Normal redirect to HTTPS while we get HTTP request
                $HTTP["url"] !~ "^/\.well-known" {
                        $HTTP["host"] =~ ".*" {
                                url.redirect = (
                                        ".*" => "https://%0$0"
                                )
                        }
                }
        }
        # Finally HTTP request, lets proxy it as we need
        $HTTP["scheme"] == "https" {
                proxy.server  = (
                        "" => (
                                (
                                        "host" => "127.0.0.1",
                                        "port" => 3000
                                )
                        )
                )
        }
}
banana_pi_m2u/lighttpd/konfigurace_vhostu.txt · Poslední úprava: 2019/01/31 03:24 autor: chytrex