Host a reverse proxy to postmarketOS and Alpine Repositories
When you don't have the access to Internet, it would be annoying to setup route and packet forwarding/masquerading on a PC. What if you just want to install a package from apk repositories, but it depends on a lot of packages? This guide shows you how to setup a reverse proxy to APK repositories on PC.
Nginx
We use nginx for example.
Installation
Debian/Ubuntu
# apt-get install nginx
Fedora/RHEL/CentOS/Rocky
# dnf install nginx
Alpine/postmarketOS
# apk add nginx
Configuration
Reverse proxy
The configs could be stored in /etc/nginx/conf.d/
or /etc/nginx/http.d/
.
In this config we use port 8000
.
# nano /etc/nginx/http.d/apk_reverse_proxy.conf
server {
listen 8000;
listen [::]:8000;
location /alpine {
proxy_pass http://dl-cdn.alpinelinux.org/alpine;
}
location /postmarketos {
proxy_pass http://mirror.postmarketos.org/postmarketos;
}
}
Local repository server
Like the other HTTP servers, Nginx can serve a local path.
Note that a standard HTTP port 80
is used in this example.
# nano /etc/nginx/http.d/apk_local_repo.conf
server {
listen 80;
listen [::]:80;
location /local {
alias /home/user/.local/var/pmbootstrap/packages;
autoindex on;
}
}
All-in-one
# nano /etc/nginx/http.d/apk_aio.conf
server {
listen 80;
listen [::]:80;
location /alpine {
proxy_pass http://dl-cdn.alpinelinux.org/alpine;
}
location /postmarketos {
proxy_pass http://mirror.postmarketos.org/postmarketos;
}
location /local {
alias /home/user/.local/var/pmbootstrap/packages;
autoindex on;
}
}
Restart
Restart to apply the changes.
systemd distros
# systemctl restart nginx
OpenRC distros
# rc-service nginx restart
Add the repository
# nano /etc/apk/repositories
http://172.16.42.2/local/edge
http://172.16.42.2:8000/postmarketos/master
http://172.16.42.2:8000/alpine/edge/main
http://172.16.42.2:8000/alpine/edge/community
http://172.16.42.2:8000/alpine/edge/testing
http://mirror.postmarketos.org/postmarketos/master
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing
Install packages
# apk update
fetch http://172.16.42.2/local/edge/aarch64/APKINDEX.tar.gz
fetch http://172.16.42.2:8000/postmarketos/master/aarch64/APKINDEX.tar.gz
fetch http://172.16.42.2:8000/alpine/edge/main/aarch64/APKINDEX.tar.gz
fetch http://172.16.42.2:8000/alpine/edge/community/aarch64/APKINDEX.tar.gz
fetch http://172.16.42.2:8000/alpine/edge/testing/aarch64/APKINDEX.tar.gz
2022-10-21 23:17:22.167857 [http://172.16.42.2/local/edge]
2022-10-22 12:50:04.451869 [http://172.16.42.2/postmarketos/master]
v20220809-6418-g42ed31be94 [http://172.16.42.2/alpine/edge/main]
v20220809-6433-g8fe86c9aea [http://172.16.42.2/alpine/edge/community]
v20220809-6434-geafcdb2299 [http://172.16.42.2/alpine/edge/testing]
# apk add postmarketos-ui-phosh