Инструменты пользователя

Инструменты сайта


freebsd:network:jail_nginx_apache

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слеваПредыдущая версия
Следующая версия
Предыдущая версия
freebsd:network:jail_nginx_apache [2020/07/02 12:06] andreifreebsd:network:jail_nginx_apache [2020/11/16 04:50] (текущий) andrei
Строка 1: Строка 1:
 ====== Сажаем apache в тюрьму, а шифровки ему туда будет носить nginx ====== ====== Сажаем apache в тюрьму, а шифровки ему туда будет носить nginx ======
- 
----- 
- 
-<note warning> 
-Статья находиться в процессе написания 
-</note> 
  
 ---- ----
Строка 23: Строка 17:
 <code> <code>
 zfs create -o mountpoint=/jails zroot/jails zfs create -o mountpoint=/jails zroot/jails
-zfs create -o quota 5G zroot/jails/empty+zfs create -o quota=5G zroot/jails/empty
 </code> </code>
  
Строка 30: Строка 24:
 <code> <code>
 cd /jails/empty cd /jails/empty
-fetch http://ftp.ru.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/base.txz+fetch http://ftp.ru.freebsd.org/pub/FreeBSD/releases/amd64/12.2-RELEASE/base.txz
 tar xvJf ./base.txz tar xvJf ./base.txz
 rm -f ./base.txz rm -f ./base.txz
Строка 121: Строка 115:
 <code> <code>
 echo 'defaultrouter="10.0.0.1" \ echo 'defaultrouter="10.0.0.1" \
-ifconfig_epair0a="10.0.0.2/24" >> /jails/www/etc/rc.conf+ifconfig_epair0a="10.0.0.2/24">> /jails/www/etc/rc.conf
 </code> </code>
  
Строка 132: Строка 126:
  
  
-===== Запуск и установка apache =====+===== Настройка jail =====
  
-====== The End ======+==== Запуск ====
  
 +Даем клетке временный доступ в интернет:
 +
 +<code>
 +pfctl -t jails -Ta 10.0.0.2
 +</code>
 +
 +Включаем и запускаем сервис:
  
 <code> <code>
Строка 141: Строка 142:
 service jail start service jail start
 </code> </code>
 +
 +Посмотреть список запушенных клеток:
  
 <code> <code>
 jls jls
 </code> </code>
 +
 +Обновляем pkg внутри клетки и устанавливаем zsh:
  
 <code> <code>
-jexec 1 /bin/sh+pkg -j www upgrade 
 +pkg -j www install zsh
 </code> </code>
 +
 +Заходим в консоль клетки:
  
 <code> <code>
-#user  nobody; +jexec www 
-worker_processes  1;+</code>
  
-# 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://trac.nginx.org/nginx/ticket/147 for more info.  +
-+
-#error_log  /var/log/nginx/error.log; +
-#+
  
-#pid        logs/nginx.pid;+Устанавливаем apache с поддержкой php и mysql:
  
 +<code>
 +pkg install apache24
 +pkg install php74 mod_php74 php74-extensions php74-mysqli
 +</code>
  
-events { +Для поддержки php добавляем в httpd.conf: 
-    worker_connections  1024; +
-}+
  
 +<code>
 +<IfModule mime_module>
  
-http { +     [...]
-    include       mime.types; +
-    default_type  application/octet-stream;+
  
-    #log_format  main  '$remote_addr $remote_user [$time_local] "$request" ' +    AddType application/x-httpd-php .php .php3 .phtml 
-    #                  '$status $body_bytes_sent "$http_referer"+    AddType application/x-httpd-php-source .phps
-    #                  '"$http_user_agent" "$http_x_forwarded_for"';+
  
-    #access_log  logs/access.log  main;+</IfModule> 
 +</code>
  
-    server_tokens  off; +Запускаем:
-    sendfile        on; +
-    #tcp_nopush     on;+
  
-    #keepalive_timeout  0; +<code> 
-    keepalive_timeout  65;+service apache24 enable 
 +service apache24 start 
 +</code>
  
-    #gzip  on; +====== NGINX ======
-        server { +
-        listen       10.30.10.79:80 default_server; +
-        server_name  localhost;+
  
-        #charset koi8-r;+Осталось только установить и настроить nginx, чтоб он работал как прокси для apache.
  
-        #access_log  logs/host.access.log  main;+<code> 
 +pkg install nginx 
 +</code>
  
-        location / { +Пример конфигурационного файла:
-            root   /usr/local/www/nginx; +
-            index  index.html index.htm; +
-        }+
  
-        #error_page  404              /404.html;+<code> 
 +worker_processes  1;
  
-        # redirect server error pages to the static page /50x.html +events { 
-        # +    worker_connections  1024
-        error_page   500 502 503 504  /50x.html; +}
-        location = /50x.html { +
-            root   /usr/local/www/nginx-dist+
-        }+
  
-        # proxy the PHP scripts to Apache listening on 127.0.0.1:80 +http { 
-        # +    include       mime.types; 
-        #location ~ \.php$ { +    default_type  application/octet-stream;
-        #    proxy_pass   http://127.0.0.1; +
-        #}+
  
-        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 +    server_tokens  off
-        # +    sendfile        on;
-        #location ~ \.php$ { +
-        #    root           html; +
-        #    fastcgi_pass   127.0.0.1:9000; +
-        #    fastcgi_index  index.php+
-        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; +
-        #    include        fastcgi_params; +
-        #}+
  
-        # deny access to .htaccess files, if Apache's document root +    keepalive_timeout  65;
-        # concurs with nginx's one +
-        # +
-        #location ~ /\.ht { +
-        #    deny  all; +
-        #} +
-    }+
  
-server { +    server { 
-    listen tst.nzgw.ru:80; +        listen       80  default_server
-    server_name tst.nzgw.ru;+        listen      443  default_server; 
 +        server_name  _; 
 +        access_log off; 
 +        log_not_found off; # Optional 
 +        return       444;
  
-    rewrite ^(.*) https://$server_name$1 permanent+ ssl_certificate /usr/local/etc/nginx/ssl/bhole.crt; 
-}+ ssl_certificate_key /usr/local/etc/nginx/ssl/bhole.key
 +    }
  
-server { +    server { 
-    listen tst.nzgw.ru:443 ssl; +        listen 80; 
-    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_certificate /usr/local/etc/ssl/fullchain1.pem+        listen 443 ssl; 
-    ssl_certificate_key /usr/local/etc/ssl/privkey1.pem; +        server_name www.nzgw.ru nzgw.ru;
-    ssl_trusted_certificate /usr/local/etc/ssl/chain1.pem;+
  
-    ssl_prefer_server_ciphers on; +        ssl_certificate /usr/local/etc/letsencrypt/live/nzgw.ru/fullchain.pem; 
-    ssl_session_timeout 1d; +        ssl_certificate_key /usr/local/etc/letsencrypt/live/nzgw.ru/privkey.pem; 
-    ssl_session_cache shared:SSL:50m; +        ssl_trusted_certificate /usr/local/etc/letsencrypt/live/nzgw.ru/chain.pem; 
-    ssl_session_tickets off;+ 
 +        ssl_prefer_server_ciphers on; 
 +        ssl_session_timeout 1d; 
 +        ssl_session_cache shared:SSL:50m; 
 +        ssl_session_tickets off;
  
     # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits     # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
-    ssl_dhparam /usr/local/etc/ssl/dh2048.pem;+        ssl_dhparam /usr/local/etc/ssl/dh2048.pem;
  
-    # intermediate configuration. tweak to your needs. +        location / { 
-#    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; +            proxy_pass http://10.0.0.2
-#    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; +            proxy_set_header Host $host; 
- +            proxy_set_header X-Real-IP $remote_addr; 
-    location / { +            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
-        proxy_pass http://10.0.0.1+            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;+
     }     }
-} 
 } }
 </code> </code>
 +
 +Запуск:
  
 <code> <code>
-openssl dhparam -out dh2048.pem 2048+service nginx enable 
 +service nginx start
 </code> </code>
 +
freebsd/network/jail_nginx_apache.1593691601.txt.gz · Последнее изменение: andrei