Last active
February 22, 2025 02:23
-
-
Save diegofcornejo/4fbabb98740fe383063e9d508b852bbb to your computer and use it in GitHub Desktop.
Deploy IPFS node with docker compose an expose with nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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