logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

i2p.md (6908B)


  1. # I2P Federation and Accessibility
  2. This guide is going to focus on the Pleroma federation aspect. The actual installation is neatly explained in the official documentation, and more likely to remain up-to-date.
  3. It might be added to this guide if there will be a need for that.
  4. We're going to use I2PD for its lightweightness over the official client.
  5. Follow the documentation according to your distro: https://i2pd.readthedocs.io/en/latest/user-guide/install/#installing
  6. How to run it: https://i2pd.readthedocs.io/en/latest/user-guide/run/
  7. ## I2P Federation
  8. There are 2 ways to go about this.
  9. One using the config, and one using external software (fedproxy). The external software works better so far.
  10. ### Using the Config
  11. **Warning:** So far, everytime I followed this way of federating using I2P, the rest of my federation stopped working. I'm leaving this here in case it will help with making it work.
  12. Assuming you're running in prod, cd to your Pleroma folder and append the following to `config/prod.secret.exs`:
  13. ```
  14. config :pleroma, :http, proxy_url: {:socks5, :localhost, 4447}
  15. ```
  16. And then run the following:
  17. ```
  18. su pleroma
  19. MIX_ENV=prod mix deps.get
  20. MIX_ENV=prod mix ecto.migrate
  21. exit
  22. ```
  23. You can restart I2PD here and finish if you don't wish to make your instance viewable or accessible over I2P.
  24. ```
  25. systemctl stop i2pd.service --no-block
  26. systemctl start i2pd.service
  27. ```
  28. *Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
  29. You can change the socks proxy port in `/etc/i2pd/i2pd.conf`.
  30. ### Using Fedproxy
  31. Fedproxy passes through clearnet requests direct to where they are going. It doesn't force anything over Tor.
  32. To use [fedproxy](https://github.com/majestrate/fedproxy) you'll need to install Golang.
  33. ```
  34. apt install golang
  35. ```
  36. Use a different user than pleroma or root. Run the following to add the Gopath to your ~/.bashrc.
  37. ```
  38. echo "export GOPATH=/home/ren/.go" >> ~/.bashrc
  39. ```
  40. Restart that bash session (you can exit and log back in).
  41. Run the following to get fedproxy.
  42. ```
  43. go get -u github.com/majestrate/fedproxy$
  44. cp $(GOPATH)/bin/fedproxy /usr/local/bin/fedproxy
  45. ```
  46. And then the following to start it for I2P only.
  47. ```
  48. fedproxy 127.0.0.1:2000 127.0.0.1:4447
  49. ```
  50. If you want to also use it for Tor, add `127.0.0.1:9050` to that command.
  51. You'll also need to modify your Pleroma config.
  52. Assuming you're running in prod, cd to your Pleroma folder and append the following to `config/prod.secret.exs`:
  53. ```
  54. config :pleroma, :http, proxy_url: {:socks5, :localhost, 2000}
  55. ```
  56. And then run the following:
  57. ```
  58. su pleroma
  59. MIX_ENV=prod mix deps.get
  60. MIX_ENV=prod mix ecto.migrate
  61. exit
  62. ```
  63. You can restart I2PD here and finish if you don't wish to make your instance viewable or accessible over I2P.
  64. ```
  65. systemctl stop i2pd.service --no-block
  66. systemctl start i2pd.service
  67. ```
  68. *Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
  69. You can change the socks proxy port in `/etc/i2pd/i2pd.conf`.
  70. ## I2P Instance Access
  71. Make your instance accessible using I2P.
  72. Add the following to your I2PD config `/etc/i2pd/tunnels.conf`:
  73. ```
  74. [pleroma]
  75. type = http
  76. host = 127.0.0.1
  77. port = 14447
  78. keys = pleroma.dat
  79. ```
  80. Restart I2PD:
  81. ```
  82. systemctl stop i2pd.service --no-block
  83. systemctl start i2pd.service
  84. ```
  85. *Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
  86. Now you'll have to find your address.
  87. To do that you can download and use I2PD tools.[^1]
  88. Or you'll need to access your web-console on localhost:7070.
  89. If you don't have a GUI, you'll have to SSH tunnel into it like this:
  90. `ssh -L 7070:127.0.0.1:7070 user@ip -p port`.
  91. Now you can access it at localhost:7070.
  92. Go to I2P tunnels page. Look for Server tunnels and you will see an address that ends with `.b32.i2p` next to "pleroma".
  93. This is your site's address.
  94. ### I2P-only Instance
  95. If creating an I2P-only instance, open `config/prod.secret.exs` and under "config :pleroma, Pleroma.Web.Endpoint," edit "https" and "port: 443" to the following:
  96. ```
  97. url: [host: "i2paddress", scheme: "http", port: 80],
  98. ```
  99. In addition to that, replace the existing nginx config's contents with the example below.
  100. ### Existing Instance (Clearnet Instance)
  101. If not an I2P-only instance, add the nginx config below to your existing config at `/etc/nginx/sites-enabled/pleroma.nginx`.
  102. And for both cases, disable CSP in Pleroma's config (STS is disabled by default) so you can define those yourself separately from the clearnet (if your instance is also on the clearnet).
  103. Copy the following into the `config/prod.secret.exs` in your Pleroma folder (/home/pleroma/pleroma/):
  104. ```
  105. config :pleroma, :http_security,
  106. enabled: false
  107. ```
  108. Use this as the Nginx config:
  109. ```
  110. proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g inactive=720m use_temp_path=off;
  111. # The above already exists in a clearnet instance's config.
  112. # If not, add it.
  113. server {
  114. listen 127.0.0.1:14447;
  115. server_name youri2paddress;
  116. # Comment to enable logs
  117. access_log /dev/null;
  118. error_log /dev/null;
  119. gzip_vary on;
  120. gzip_proxied any;
  121. gzip_comp_level 6;
  122. gzip_buffers 16 8k;
  123. gzip_http_version 1.1;
  124. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml;
  125. client_max_body_size 16m;
  126. location / {
  127. add_header X-XSS-Protection "1; mode=block";
  128. add_header X-Permitted-Cross-Domain-Policies none;
  129. add_header X-Frame-Options DENY;
  130. add_header X-Content-Type-Options nosniff;
  131. add_header Referrer-Policy same-origin;
  132. add_header X-Download-Options noopen;
  133. proxy_http_version 1.1;
  134. proxy_set_header Upgrade $http_upgrade;
  135. proxy_set_header Connection "upgrade";
  136. proxy_set_header Host $http_host;
  137. proxy_pass http://localhost:4000;
  138. client_max_body_size 16m;
  139. }
  140. location /proxy {
  141. proxy_cache pleroma_media_cache;
  142. proxy_cache_lock on;
  143. proxy_ignore_client_abort on;
  144. proxy_pass http://localhost:4000;
  145. }
  146. }
  147. ```
  148. reload Nginx:
  149. ```
  150. systemctl stop i2pd.service --no-block
  151. systemctl start i2pd.service
  152. ```
  153. *Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
  154. You should now be able to both access your instance using I2P and federate with other I2P instances!
  155. [^1]: [I2PD tools](https://github.com/purplei2p/i2pd-tools) to print information about a router info file or an I2P private key, generate an I2P private key, and generate vanity addresses.
  156. ### Possible Issues
  157. Will be added when encountered.