centos_nginx_backuppc4.x
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| centos_nginx_backuppc4.x [2018/02/15 17:50] – [CentOS / Fedora + Nginx + Backuppc] k2patel | centos_nginx_backuppc4.x [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== CentOS / Fedora + Nginx + Backuppc ====== | + | ====== CentOS |
| This combination gave me no documentation online, Recently Backuppc is available as SCGI Script version.\\ | This combination gave me no documentation online, Recently Backuppc is available as SCGI Script version.\\ | ||
| Line 23: | Line 23: | ||
| ==== Configuration ==== | ==== Configuration ==== | ||
| - | In configuration i've only changed few of the options to make it work under browser. | + | === In configuration i've only changed few of the options to make it work under browser. |
| <code diff| / | <code diff| / | ||
| Line 113: | Line 114: | ||
| # | # | ||
| # CSS stylesheet " | # CSS stylesheet " | ||
| + | </ | ||
| + | |||
| + | === Nginx Configuration === | ||
| + | <code bash | / | ||
| + | worker_processes | ||
| + | |||
| + | events { | ||
| + | worker_connections | ||
| + | } | ||
| + | |||
| + | http { | ||
| + | include | ||
| + | default_type | ||
| + | |||
| + | sendfile | ||
| + | |||
| + | keepalive_timeout | ||
| + | |||
| + | gzip on; | ||
| + | |||
| + | server { | ||
| + | listen | ||
| + | server_name | ||
| + | |||
| + | return 302 https:// | ||
| + | |||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen | ||
| + | server_name | ||
| + | |||
| + | ssl on; | ||
| + | ssl_certificate | ||
| + | ssl_certificate_key | ||
| + | ssl_trusted_certificate / | ||
| + | |||
| + | # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months) | ||
| + | add_header Strict-Transport-Security max-age=63072000; | ||
| + | |||
| + | # OCSP Stapling --- | ||
| + | # fetch OCSP records from URL in ssl_certificate and cache them | ||
| + | ssl_stapling on; | ||
| + | ssl_stapling_verify off; | ||
| + | # modern configuration. tweak to your needs. | ||
| + | ssl_protocols TLSv1.2; | ||
| + | ssl_ciphers ' | ||
| + | ssl_prefer_server_ciphers on; | ||
| + | |||
| + | ssl_session_timeout 1d; | ||
| + | ssl_session_cache shared: | ||
| + | ssl_session_tickets off; | ||
| + | |||
| + | add_header Strict-Transport-Security max-age=63072000; | ||
| + | add_header X-Frame-Options DENY; | ||
| + | add_header X-Content-Type-Options nosniff; | ||
| + | |||
| + | error_page | ||
| + | location = /50x.html { | ||
| + | root / | ||
| + | } | ||
| + | |||
| + | access_log | ||
| + | error_log | ||
| + | |||
| + | location / { | ||
| + | auth_basic " | ||
| + | auth_basic_user_file / | ||
| + | root / | ||
| + | return 302 http:// | ||
| + | index BackupPC.html; | ||
| + | } | ||
| + | |||
| + | location /BackupPC { | ||
| + | alias / | ||
| + | index BackupPC.html; | ||
| + | } | ||
| + | |||
| + | #location ~\.cgi$ { | ||
| + | location ~ ^/ | ||
| + | auth_basic " | ||
| + | auth_basic_user_file / | ||
| + | gzip off; | ||
| + | include / | ||
| + | fastcgi_pass localhost: | ||
| + | |||
| + | fastcgi_param REMOTE_ADDR | ||
| + | fastcgi_param REMOTE_USER | ||
| + | fastcgi_param SCRIPT_FILENAME / | ||
| + | } | ||
| + | |||
| + | location ~ /\.ht { | ||
| + | deny all; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
| ==== Required Third party scripts ==== | ==== Required Third party scripts ==== | ||
| + | <code perl | / | ||
| + | # | ||
| + | |||
| + | use FCGI; | ||
| + | use Socket; | ||
| + | use POSIX qw(setsid); | ||
| + | |||
| + | require ' | ||
| + | |||
| + | & | ||
| + | |||
| + | #this keeps the program alive or something after exec' | ||
| + | END() { } BEGIN() { } | ||
| + | *CORE:: | ||
| + | eval q{exit}; | ||
| + | if ($@) { | ||
| + | exit unless $@ =~ / | ||
| + | }; | ||
| + | |||
| + | &main; | ||
| + | |||
| + | sub daemonize() { | ||
| + | chdir '/' | ||
| + | defined(my $pid = fork) or die " | ||
| + | exit if $pid; | ||
| + | setsid | ||
| + | umask 0; | ||
| + | } | ||
| + | |||
| + | sub main { | ||
| + | $socket = FCGI:: | ||
| + | $request = FCGI:: | ||
| + | if ($request) { request_loop()}; | ||
| + | FCGI:: | ||
| + | } | ||
| + | |||
| + | sub request_loop { | ||
| + | while( $request-> | ||
| + | | ||
| + | # | ||
| + | | ||
| + | | ||
| + | if (($req_params{' | ||
| + | my $bytes_read = 0; | ||
| + | while ($bytes_read < $req_len) { | ||
| + | my $data = ''; | ||
| + | my $bytes = read(STDIN, $data, ($req_len - $bytes_read)); | ||
| + | last if ($bytes == 0 || !defined($bytes)); | ||
| + | $stdin_passthrough .= $data; | ||
| + | $bytes_read += $bytes; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | #running the cgi app | ||
| + | if ( (-x $req_params{SCRIPT_FILENAME}) && | ||
| + | (-s $req_params{SCRIPT_FILENAME}) && | ||
| + | (-r $req_params{SCRIPT_FILENAME}) | ||
| + | ){ | ||
| + | pipe(CHILD_RD, | ||
| + | my $pid = open(KID_TO_READ, | ||
| + | unless(defined($pid)) { | ||
| + | print(" | ||
| + | print " | ||
| + | print " | ||
| + | next; | ||
| + | } | ||
| + | if ($pid > 0) { | ||
| + | close(CHILD_RD); | ||
| + | print PARENT_WR $stdin_passthrough; | ||
| + | close(PARENT_WR); | ||
| + | |||
| + | while(my $s = < | ||
| + | close KID_TO_READ; | ||
| + | waitpid($pid, | ||
| + | } else { | ||
| + | foreach $key ( keys %req_params){ | ||
| + | | ||
| + | } | ||
| + | # cd to the script' | ||
| + | if ($req_params{SCRIPT_FILENAME} =~ / | ||
| + | chdir $1; | ||
| + | } | ||
| + | |||
| + | close(PARENT_WR); | ||
| + | close(STDIN); | ||
| + | # | ||
| + | syscall(& | ||
| + | # | ||
| + | exec($req_params{SCRIPT_FILENAME}); | ||
| + | die(" | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | print(" | ||
| + | print " | ||
| + | print "exist or is not executable by this process.\n"; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === Systemd Script === | ||
| + | <code bash | / | ||
| + | [Unit] | ||
| + | Description=Fast CGI wrapper | ||
| + | After=network.target | ||
| + | |||
| + | [Service] | ||
| + | Type=forking | ||
| + | TimeoutStopSec=0 | ||
| + | User=backuppc | ||
| + | Group=backuppc | ||
| + | ExecStart=/ | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | </ | ||
| + | ==== Final Note ==== | ||
| + | Once everything is configured you should be able to access your backuppc using user admin.\\ | ||
centos_nginx_backuppc4.x.1518717055.txt.gz · Last modified: 2020/08/10 02:28 (external edit)
