freebsd:network:jail_nginx_apache
Различия
Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слеваПредыдущая версияСледующая версия | Предыдущая версия | ||
| freebsd:network:jail_nginx_apache [2020/07/02 11:59] – [Настройка jail] andrei | freebsd:network:jail_nginx_apache [2020/11/16 04:50] (текущий) – andrei | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| ====== Сажаем apache в тюрьму, | ====== Сажаем apache в тюрьму, | ||
| - | |||
| - | ---- | ||
| - | |||
| - | <note warning> | ||
| - | Статья находиться в процессе написания | ||
| - | </ | ||
| ---- | ---- | ||
| Строка 23: | Строка 17: | ||
| < | < | ||
| zfs create -o mountpoint=/ | zfs create -o mountpoint=/ | ||
| - | zfs create -o quota 5G zroot/ | + | zfs create -o quota=5G zroot/ |
| </ | </ | ||
| Строка 30: | Строка 24: | ||
| < | < | ||
| cd / | cd / | ||
| - | fetch http:// | + | fetch http:// |
| tar xvJf ./base.txz | tar xvJf ./base.txz | ||
| rm -f ./base.txz | rm -f ./base.txz | ||
| Строка 117: | Строка 111: | ||
| </ | </ | ||
| - | Так же перед запуском надо настроить сеть внутри самой клетки. Для этого создаем файл | + | Так же перед запуском надо настроить сеть внутри самой клетки. Для этого создаем файлы rc.conf: |
| < | < | ||
| - | # | + | echo 'defaultrouter=" |
| - | defaultrouter=" | + | ifconfig_epair0a=" |
| - | ifconfig_epair0a=" | + | |
| </ | </ | ||
| - | и файл | + | и файл resolv.conf: |
| < | < | ||
| - | nameserver 10.0.0.1 | + | echo 'nameserver 10.0.0.1' >> / |
| </ | </ | ||
| - | ===== Запуск ===== | + | ===== Настройка jail ===== |
| + | |||
| + | ==== Запуск ==== | ||
| + | |||
| + | Даем клетке временный доступ в интернет: | ||
| + | |||
| + | < | ||
| + | pfctl -t jails -Ta 10.0.0.2 | ||
| + | </ | ||
| + | |||
| + | Включаем и запускаем сервис: | ||
| < | < | ||
| Строка 139: | Строка 142: | ||
| service jail start | service jail start | ||
| </ | </ | ||
| + | |||
| + | Посмотреть список запушенных клеток: | ||
| < | < | ||
| jls | jls | ||
| </ | </ | ||
| + | |||
| + | Обновляем pkg внутри клетки и устанавливаем zsh: | ||
| < | < | ||
| - | jexec 1 /bin/sh | + | pkg -j www upgrade |
| + | pkg -j www install zsh | ||
| </ | </ | ||
| + | |||
| + | Заходим в консоль клетки: | ||
| < | < | ||
| - | #user nobody; | + | jexec www |
| - | worker_processes | + | </ |
| - | # This default error log path is compiled-in to make sure configuration parsing | + | ==== Установка и настройка apache ==== |
| - | # errors are logged somewhere, especially during unattended boot when stderr | + | |
| - | # isn't normally logged anywhere. This path will be touched on every nginx | + | |
| - | # start regardless of error log location configured here. See | + | |
| - | # https:// | + | |
| - | # | + | |
| - | # | + | |
| - | # | + | |
| - | #pid logs/ | + | Устанавливаем apache с поддержкой php и mysql: |
| + | < | ||
| + | pkg install apache24 | ||
| + | pkg install php74 mod_php74 php74-extensions php74-mysqli | ||
| + | </ | ||
| - | events { | + | Для поддержки php добавляем в httpd.conf: |
| - | worker_connections | + | |
| - | } | + | |
| + | < | ||
| + | < | ||
| - | http { | + | [...] |
| - | include | + | |
| - | default_type | + | |
| - | | + | |
| - | | + | |
| - | # '" | + | |
| - | # | + | </IfModule> |
| + | </ | ||
| - | server_tokens | + | Запускаем: |
| - | sendfile | + | |
| - | # | + | |
| - | # | + | < |
| - | | + | service apache24 enable |
| + | service apache24 start | ||
| + | </ | ||
| - | #gzip on; | + | ====== NGINX ====== |
| - | server { | + | |
| - | listen | + | |
| - | server_name | + | |
| - | #charset koi8-r; | + | Осталось только установить и настроить nginx, чтоб он работал как прокси для apache. |
| - | # | + | < |
| + | pkg install nginx | ||
| + | </code> | ||
| - | location / { | + | Пример конфигурационного файла: |
| - | root / | + | |
| - | index index.html index.htm; | + | |
| - | } | + | |
| - | # | + | < |
| + | worker_processes | ||
| - | # redirect server error pages to the static page /50x.html | + | events { |
| - | # | + | |
| - | error_page | + | } |
| - | location = /50x.html { | + | |
| - | root / | + | |
| - | } | + | |
| - | # proxy the PHP scripts to Apache listening on 127.0.0.1: | + | http { |
| - | # | + | |
| - | #location ~ \.php$ { | + | |
| - | # | + | |
| - | #} | + | |
| - | # pass the PHP scripts to FastCGI server listening on 127.0.0.1: | + | server_tokens |
| - | # | + | |
| - | #location ~ \.php$ { | + | |
| - | # root | + | |
| - | # fastcgi_pass | + | |
| - | # fastcgi_index | + | |
| - | # | + | |
| - | # include | + | |
| - | #} | + | |
| - | # deny access to .htaccess files, if Apache' | + | keepalive_timeout |
| - | # concurs with nginx' | + | |
| - | # | + | |
| - | #location ~ /\.ht { | + | |
| - | # deny all; | + | |
| - | #} | + | |
| - | } | + | |
| - | server { | + | |
| - | listen | + | listen |
| - | server_name | + | |
| + | | ||
| + | access_log off; | ||
| + | log_not_found off; # Optional | ||
| + | return | ||
| - | rewrite ^(.*) https://$server_name$1 permanent; | + | ssl_certificate / |
| - | } | + | ssl_certificate_key |
| + | } | ||
| - | server { | + | |
| - | listen | + | listen |
| - | server_name tst.nzgw.ru; | + | server_name www.nzgw.ru nzgw.ru; |
| - | root /vhosts/www.example.net; | + | return 301 https://www.nzgw.ru$request_uri; |
| + | } | ||
| - | # ssl on; | + | server { |
| - | | + | |
| - | | + | |
| - | ssl_trusted_certificate / | + | |
| - | | + | ssl_certificate / |
| - | ssl_session_timeout 1d; | + | ssl_certificate_key / |
| - | ssl_session_cache shared: | + | ssl_trusted_certificate / |
| - | ssl_session_tickets off; | + | |
| + | | ||
| + | ssl_session_timeout 1d; | ||
| + | ssl_session_cache shared: | ||
| + | ssl_session_tickets off; | ||
| # Diffie-Hellman parameter for DHE ciphersuites, | # Diffie-Hellman parameter for DHE ciphersuites, | ||
| - | | + | |
| - | # intermediate configuration. tweak to your needs. | + | |
| - | # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | + | proxy_pass http:// |
| - | # ssl_ciphers ' | + | proxy_set_header Host $host; |
| - | + | proxy_set_header X-Real-IP $remote_addr; | |
| - | | + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| - | proxy_pass http:// | + | proxy_set_header X-Forwarded-Proto https; |
| - | proxy_set_header Host $host; | + | } |
| - | proxy_set_header X-Real-IP $remote_addr; | + | |
| - | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | + | |
| - | proxy_set_header X-Forwarded-Proto https; | + | |
| } | } | ||
| - | } | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | Запуск: | ||
| < | < | ||
| - | openssl dhparam -out dh2048.pem 2048 | + | service nginx enable |
| + | service nginx start | ||
| </ | </ | ||
| + | |||
freebsd/network/jail_nginx_apache.1593691164.txt.gz · Последнее изменение: — andrei
