Skip to content

Commit adc858b

Browse files
committed
adblock2privoxy: Update to version 2.1.0
* Use TLS for CSS server to avoid mixed content errors * Add --useHTTP option * Update to ghc 8.10.7, lts-18.18 resolver
1 parent 6cffd44 commit adc858b

12 files changed

Lines changed: 572 additions & 144 deletions

File tree

README.md

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ If no source URLs are specified, task file is used to determine sources: previou
103103
Css files output path
104104
-d DOMAIN, --domainCSS=DOMAIN
105105
Domain of CSS web server (required for Element Hide functionality)
106+
-u, --useHTTP
107+
Use HTTP for CSS web server; the default is HTTPS to avoid mixed content
106108
-t PATH, --taskFile=PATH
107109
Path to task file containing urls to process and options.
108110
-f, --forced
@@ -183,16 +185,35 @@ Nginx config: add following lines into http section of `nginx.conf` file
183185

184186
```
185187
server {
186-
listen 80;
188+
listen www.example.com:443;
187189
#ab2p css domain name (optional, should be equal to --domainCSS parameter)
188190
server_name www.example.com;
189191
192+
ssl on;
193+
ssl_certificate certs/adblock2privoxy-nginx.chain.pem;
194+
ssl_certificate_key certs/adblock2privoxy-nginx.key.pem.decrypted;
195+
# use modern crypto
196+
# https://ssl-config.mozilla.org
197+
ssl_protocols TLSv1.3;
198+
ssl_prefer_server_ciphers on;
199+
ssl_dhparam certs/dhparam.pem;
200+
ssl_ciphers TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:EECDH+AESGCM:EDH+AESGCM;
201+
ssl_ecdh_curve secp384r1;
202+
ssl_session_timeout 180m;
203+
ssl_session_cache shared:SSL:20m;
204+
ssl_session_tickets off;
205+
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
206+
207+
# comply with Content Security policy
208+
add_header Content-Type "text/css";
209+
add_header X-Content-Type-Options nosniff;
210+
190211
#root = --webDir parameter value
191212
root /var/www/privoxy;
192213
193214
location ~ ^/[^/.]+\..+/ab2p.css$ {
194215
# first reverse domain names order
195-
rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last;
216+
rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last;
196217
}
197218
198219
location ~ (^.*/+)[^/]+/+ab2p.css {
@@ -203,6 +224,82 @@ server {
203224
}
204225
```
205226

227+
The CSS web server must use HTTPS to comply with standard Content
228+
Security policies that prohibit mixed content. Example
229+
[nginx.conf](./nginx.conf) and [openssl.cnf](openssl.cnf) files are
230+
included in this repo that generate the necessary PKI. Modify
231+
these as appropriate. Example `openssl` commands:
232+
```bash
233+
mkdir certs && cd certs
234+
touch index.txt
235+
echo 1000 > serial
236+
237+
# CA certificate encrypted key passphrase, both -passin and -passout
238+
sf-pwgen --algorithm memorable --count 2 --length 24 2>/dev/null | paste -s -d -- '-' \
239+
1>passphrase.txt || true
240+
if [ $(head -1 passphrase.txt | wc -c) < 20 ]; then \
241+
openssl rand -base64 23 1>passphrase.txt 2>/dev/null; fi
242+
cat passphrase.txt passphrase.txt > passphrase-dbl.txt \
243+
&& mv passphrase-dbl.txt passphrase.txt \
244+
|| rm -f passphrase-dbl.txt
245+
chmod go-rwx passphrase.txt
246+
247+
# CA encrypted key
248+
# EC
249+
openssl genpkey -out ca.key.pem -algorithm EC \
250+
-pkeyopt ec_paramgen_curve:P-256 -aes256 \
251+
-pass file:passphrase.txt
252+
253+
# RSA
254+
# # openssl genpkey -out ca.key.pem -algorithm RSA \
255+
# # -pkeyopt rsa_keygen_bits:2048 -aes256 \
256+
# # -pass file:passphrase.txt
257+
258+
# CA certificate
259+
openssl req -config openssl.cnf \
260+
-new -x509 -days 3650 -sha256 -extensions v3_ca -out certs/ca.cert.pem \
261+
-key ca.key.pem -passin file:passphrase.txt -batch
262+
263+
# CA certificate text verification
264+
openssl x509 -text -noout -in ca.cert.pem
265+
266+
# CA certificate openssl self-verification
267+
openssl verify -CAfile ca.cert.pem ca.cert.pem
268+
269+
# Server certificate encrypted key and decrypted key
270+
openssl genpkey -out adblock2privoxy-nginx.key.pem \
271+
-algorithm EC -pkeyopt ec_paramgen_curve:P-384 -aes256 \
272+
-pass file:passphrase.txt
273+
openssl ec -in adblock2privoxy-nginx.key.pem -passin file:passphrase.txt \
274+
-out adblock2privoxy-nginx.key.pem.decrypted
275+
chmod go-rwx adblock2privoxy-nginx.key.pem.decrypted
276+
277+
# Server certificate CSR
278+
openssl req -config openssl.cnf -new -sha256 -extensions server_cert \
279+
-key adblock2privoxy-nginx.key.pem -passin file:passphrase.txt \
280+
-out adblock2privoxy-nginx.csr.pem -batch
281+
282+
# Server certificate (825 days maximum validity)
283+
# https://support.apple.com/en-us/HT210176
284+
openssl ca -config openssl.cnf -days 825 -notext -md sha256 \
285+
-extensions server_cert -in adblock2privoxy-nginx.csr.pem \
286+
-out adblock2privoxy-nginx.cert.pem -passin file:passphrase.txt \
287+
-subj '/CN=adblock2privoxy-nginx' -batch
288+
289+
# Server certificate chain of trust
290+
cat adblock2privoxy-nginx.cert.pem ca.cert.pem > adblock2privoxy-nginx.chain.pem
291+
292+
# Server certificate text
293+
openssl x509 -in adblock2privoxy-nginx.cert.pem -text -noout
294+
295+
# Server certificate and chain validity
296+
openssl verify -CAfile ca.cert.pem adblock2privoxy-nginx.cert.pem
297+
openssl verify -CAfile ca.cert.pem adblock2privoxy-nginx.chain.pem
298+
299+
# DH params
300+
openssl dhparam -out dhparam.pem 2048
301+
```
302+
206303
Apache config: put following lines into
207304

208305
* for linux: `/etc/apache2/sites-available/000-default.conf` (replace existing content)
Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
1-
name: adblock2privoxy-utils
2-
version: 2.0.2
3-
cabal-version: >= 1.10
4-
build-type: Simple
5-
tested-with: GHC==8.10.4
6-
author: Alexey Zubritsky <adblock2privoxy@zubr.me>, Steven Thomas Smith <steve.t.smith@gmail.com>
7-
homepage: https://github.com/essandess/adblock2privoxy
8-
category: Web
9-
license: GPL-3
10-
license-file: LICENSE
11-
synopsis: Helper utilities and scripts for adblock2privoxy project
1+
name: adblock2privoxy-utils
2+
version: 2.1.0
3+
cabal-version: >= 1.10
4+
build-type: Simple
5+
tested-with: GHC==8.10.7
6+
author: Alexey Zubritsky <adblock2privoxy@zubr.me>, Steven Thomas Smith <steve.t.smith@gmail.com>
7+
homepage: https://github.com/essandess/adblock2privoxy
8+
category: Web
9+
license: GPL-3
10+
license-file: LICENSE
11+
synopsis: Helper utilities and scripts for adblock2privoxy project
1212
description:
13-
* Creates config files for PRM packaging using values from cabal file
14-
* Creates man help files from README
15-
.
16-
This package is only needed to pubish new releases of adblock2privoxy in hackage
17-
.
18-
It is not needed for packaging and execution of adblock2privoxy
19-
13+
* Creates config files for PRM packaging using values from cabal file
14+
* Creates man help files from README
15+
.
16+
This package is only needed to pubish new releases of adblock2privoxy in hackage
17+
.
18+
It is not needed for packaging and execution of adblock2privoxy
2019

2120
executable adblock2privoxy-utils
22-
hs-source-dirs: src
23-
main-is: Main.hs
24-
ghc-options: -Wall
25-
default-language: Haskell2010
21+
hs-source-dirs: src
22+
main-is: Main.hs
23+
ghc-options: -Wall
24+
default-language: Haskell2010
2625
default-extensions:
27-
FlexibleInstances
26+
FlexibleInstances
2827
build-depends:
29-
base >= 4 && < 5,
30-
pandoc,
31-
Cabal >=1.6,
32-
pandoc-types >=1.12.3,
33-
filepath,
34-
directory,
35-
time,
36-
old-locale,
37-
MissingH
28+
base >= 4 && < 5,
29+
pandoc,
30+
Cabal >=1.6,
31+
pandoc-types >=1.12.3,
32+
filepath,
33+
directory,
34+
time,
35+
old-locale,
36+
MissingH
3837
other-modules:
39-
CabalTemplate
40-
DebControl
41-
ManPage
42-
RpmSpec
43-
RootPath
38+
CabalTemplate
39+
DebControl
40+
ManPage
41+
RpmSpec
42+
RootPath
4443

4544
source-repository this
46-
type: git
47-
location: https://github.com/essandess/adblock2privoxy.git
48-
subdir: adblock2privoxy-utils
49-
tag: v2.0.2
45+
type: git
46+
location: https://github.com/essandess/adblock2privoxy.git
47+
subdir: adblock2privoxy-utils
48+
tag: v2.1.0

0 commit comments

Comments
 (0)