Skip to content

Commit b01817b

Browse files
committed
Adds squid to dev/CI stacks
- for testing forwarded ip address later
1 parent 5aeb99b commit b01817b

File tree

6 files changed

+127
-7
lines changed

6 files changed

+127
-7
lines changed

docker/dev/squid.conf

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# WELCOME TO SQUID 6.6
2+
# ----------------------------
3+
#
4+
# This is the documentation for the Squid configuration file.
5+
# This documentation can also be found online at:
6+
# http://www.squid-cache.org/Doc/config/
7+
#
8+
# You may wish to look at the Squid home page and wiki for the
9+
# FAQ and other documentation:
10+
# http://www.squid-cache.org/
11+
# https://wiki.squid-cache.org/SquidFaq
12+
# https://wiki.squid-cache.org/ConfigExamples
13+
#
14+
15+
# Example rule allowing access from your local networks.
16+
# Adapt to list your (internal) IP networks from where browsing
17+
# should be allowed
18+
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
19+
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN)
20+
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
21+
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
22+
acl localnet src 172.0.0.0/8
23+
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN)
24+
acl localnet src fc00::/7 # RFC 4193 local private network range
25+
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
26+
27+
acl SSL_ports port 443
28+
acl Safe_ports port 80 # http
29+
acl Safe_ports port 81
30+
acl Safe_ports port 443 # https
31+
32+
#
33+
# Recommended minimum Access Permission configuration:
34+
#
35+
# Deny requests to certain unsafe ports
36+
http_access deny !Safe_ports
37+
38+
# Deny CONNECT to other than secure SSL ports
39+
http_access deny CONNECT !SSL_ports
40+
41+
# Only allow cachemgr access from localhost
42+
http_access allow localhost manager
43+
http_access deny manager
44+
45+
# This default configuration only allows localhost requests because a more
46+
# permissive Squid installation could introduce new attack vectors into the
47+
# network by proxying external TCP connections to unprotected services.
48+
http_access allow localhost
49+
50+
# The two deny rules below are unnecessary in this default configuration
51+
# because they are followed by a "deny all" rule. However, they may become
52+
# critically important when you start allowing external requests below them.
53+
54+
# Protect web applications running on the same server as Squid. They often
55+
# assume that only local users can access them at "localhost" ports.
56+
http_access deny to_localhost
57+
58+
# Protect cloud servers that provide local users with sensitive info about
59+
# their server via certain well-known link-local (a.k.a. APIPA) addresses.
60+
http_access deny to_linklocal
61+
62+
#
63+
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
64+
#
65+
include /etc/squid/conf.d/*.conf
66+
67+
# For example, to allow access from your local networks, you may uncomment the
68+
# following rule (and/or add rules that match your definition of "local"):
69+
# http_access allow localnet
70+
71+
# And finally deny all other access to this proxy
72+
http_access deny all
73+
74+
# Squid normally listens to port 3128
75+
http_port 3128
76+
77+
# Leave coredumps in the first cache dir
78+
coredump_dir /var/spool/squid
79+
80+
#
81+
# Add any of your own refresh_pattern entries above these.
82+
#
83+
refresh_pattern ^ftp: 1440 20% 10080
84+
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
85+
refresh_pattern \/(Packages|Sources)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
86+
refresh_pattern \/Release(|\.gpg)$ 0 0% 0 refresh-ims
87+
refresh_pattern \/InRelease$ 0 0% 0 refresh-ims
88+
refresh_pattern \/(Translation-.*)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
89+
# example pattern for deb packages
90+
#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
91+
refresh_pattern . 0 20% 4320
92+

docker/docker-compose.ci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
networks:
2323
fulltest:
2424
aliases:
25+
- npm
2526
- website1.example.com
2627
- website2.example.com
2728
- website3.example.com
@@ -92,13 +93,25 @@ services:
9293
dockerfile: test/cypress/Dockerfile
9394
environment:
9495
CYPRESS_baseUrl: 'http://fullstack:81'
96+
HTTP_PROXY: 'http://squid:3128'
97+
HTTPS_PROXY: 'http://squid:3128'
9598
volumes:
9699
- 'cypress_logs:/results'
97100
- './dev/resolv.conf:/etc/resolv.conf:ro'
101+
- '/etc/localtime:/etc/localtime:ro'
98102
command: cypress run --browser chrome --config-file=cypress/config/ci.js
99103
networks:
100104
- fulltest
101105

106+
squid:
107+
image: ubuntu/squid
108+
volumes:
109+
- './dev/squid.conf:/etc/squid/squid.conf:ro'
110+
- './dev/resolv.conf:/etc/resolv.conf:ro'
111+
- '/etc/localtime:/etc/localtime:ro'
112+
networks:
113+
- fulltest
114+
102115
volumes:
103116
cypress_logs:
104117
npm_data_ci:

docker/docker-compose.dev.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ services:
1212
- 3081:81
1313
- 3443:443
1414
networks:
15-
- nginx_proxy_manager
15+
nginx_proxy_manager:
16+
aliases:
17+
- website1.example.com
18+
- website2.example.com
19+
- website3.example.com
1620
environment:
1721
PUID: 1000
1822
PGID: 1000
@@ -65,6 +69,17 @@ services:
6569
depends_on:
6670
- npm
6771

72+
squid:
73+
image: ubuntu/squid
74+
container_name: npm_squid
75+
volumes:
76+
- './dev/squid.conf:/etc/squid/squid.conf:ro'
77+
- '/etc/localtime:/etc/localtime:ro'
78+
networks:
79+
- nginx_proxy_manager
80+
ports:
81+
- 8128:3128
82+
6883
volumes:
6984
npm_data:
7085
name: npm_core_data

test/cypress/config/ci.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module.exports = defineConfig({
1515
return require("../plugins/index.js")(on, config);
1616
},
1717
env: {
18-
swaggerBase: '{{baseUrl}}/api/schema',
18+
swaggerBase: 'http://npm:81/api/schema',
1919
},
20-
baseUrl: 'http://localhost:1234',
20+
baseUrl: 'http://npm:81',
2121
}
2222
});

test/cypress/config/dev.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module.exports = defineConfig({
1515
return require("../plugins/index.js")(on, config);
1616
},
1717
env: {
18-
swaggerBase: '{{baseUrl}}/api/schema',
18+
swaggerBase: 'http://npm:81/api/schema',
1919
},
20-
baseUrl: 'http://localhost:1234',
20+
baseUrl: 'http://npm:81',
2121
}
2222
});

test/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"mocha-junit-reporter": "^2.2.1"
2020
},
2121
"scripts": {
22-
"cypress": "cypress open --config-file=cypress/config/dev.js --config baseUrl=${BASE_URL:-http://127.0.0.1:3081}",
23-
"cypress:headless": "cypress run --config-file=cypress/config/dev.js --config baseUrl=${BASE_URL:-http://127.0.0.1:3081}"
22+
"cypress": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress open --config-file=cypress/config/dev.js",
23+
"cypress:headless": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress run --config-file=cypress/config/dev.js"
2424
},
2525
"author": "",
2626
"license": "ISC"

0 commit comments

Comments
 (0)