Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active February 22, 2025 02:23
Show Gist options
  • Save diegofcornejo/4fbabb98740fe383063e9d508b852bbb to your computer and use it in GitHub Desktop.
Save diegofcornejo/4fbabb98740fe383063e9d508b852bbb to your computer and use it in GitHub Desktop.
Deploy IPFS node with docker compose an expose with nginx
services:
ipfs:
image: ipfs/kubo:latest
container_name: ipfs
volumes:
- ./ipfs_path:/data/ipfs
- ./ipfs_export:/export
- ./ipfs_fuse:/ipfs
- ./ipns_fuse:/ipns
environment:
- IPFS_PATH=/data/ipfs
ports:
- "4001:4001/tcp"
- "4001:4001/udp"
- "127.0.0.1:4002:5001"
- "127.0.0.1:4003:8080"
restart: unless-stopped
server {
server_name ipfs.mydomain.com;
listen 80;
# Redirect to webUI
location / {
return 301 http://$host/webui/;
}
# WebUI
location /webui/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/passwords/ipfs;
proxy_pass http://127.0.0.1:4002/webui/;
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 $scheme;
}
# API (Require authentication)
location /api/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/passwords/ipfs;
proxy_pass http://127.0.0.1:4002/api/;
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 $scheme;
}
# IPFS Gateway (Restricted access to Gateway)
location ~ ^/(ipfs|ipns)/ {
auth_basic "Restricted"; # Commented out to allow public access
auth_basic_user_file /etc/nginx/passwords/ipfs; # Commented out to allow public access
proxy_pass http://127.0.0.1:4003;
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 $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment