Because ActivityPub is quite generic, the goal here is not the implement every aspect of ActivityPub but just a coherent subset that can be used for understanding the protocol as well as for testing. Thus the use case is microblogging: users can only publish or like notes and follow each others.
You can use a reverse proxy to simulate remote servers.
First add two new hosts in your hosts file:
$ cat /etc/hosts
...
127.0.1.1 alice.local bob.local
...
Then add two new virtual hosts for alice.local and bob.local.
Here is an example nginx configuration file to achieve that:
server {
listen 80;
index index.html index.htm;
server_name alice.local;
server_name_in_redirect off;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $host;
}
}
Copy the file and change `alice.local` to `bob.local` and the port to `8001`.
You'll also need two different Django configuration files. So copy `activitypub/settings.py` to `activitypub/settings-bob.py` and change the following values:
$ cat activitypub/settings-bob.py
...
ACTIVITYPUB_DOMAIN = "alice.local" # or bob.local
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'alice.sqlite3'), # or bob.sqlite3
}
}
Now you can run the migrations for alice (default) and bob:
Check that the servers are reachable via the correct hosts:
- [http://alice.local](http://alice.local)
- [http://bob.local](http://bob.local)
If all works correctly they should be able to reach each others. To verify that, we need to first create users. The simplest way is to do it via the python shell:
$ ./manage.py shell
...
>>> from activitypub.models import Person
>>> alice = Person(username="alice", name="Alice in Wonderland")
>>> alice.save()
Alice's actor representation should be available at http://alice.local/@alice.