Q:

What principles or concepts exist to communicate between two webservers securely?

I have two websites/servers which should share some information in both directions securely. For example when a visitor does some action on site A, the data is posted from server A to server B. When a user does some other action, I might need to get data from server B to server A.
I am willing to use http protocol for communication between servers. Both servers use Django. What concepts exist for making secure connection? What python and django libraries should I have a look at for server-side communication?
What comes into my mind now is RESTful Web Services, some kind of secure token or private and public keys. What concepts should I be searching for?

A:

Restful web-service endpoints on each application makes reasonable sense based on the assumption you want to stick with Django/Python for this.
I would suggest using Django Rest Framework and make use of token based authentication with pre-configured "shared keys" (which you can periodically rotate). 
With token-based auth, your keys are passed in the HTTP header so you really ought to be running with the endpoints under secure HTTP connections. See the Django docs on SSL/HTTPS for how to set this up securely.
If the trigger for transferring data is a time sensitive web request, then you should consider making the REST web-service request asynchronous. You can use Celery tasks for this purpose. Celery is also going to be nice as it'll give you quite some options, such as automatic retry, in how you deal with errors with the synchronisation services.

