I have the REST api configured to allow POSTing new users to /entity/user
. On my local machine, it works just fine. Once I push up to my remote host, it stops working.
The key difference is that on my local machine, my site is running in a docker container bound to port 6050, so all rest calls go to localhost:6050
.
On my remote host, I have docker configured behind an Apache 2.4 reverse proxy. So the docker container is still bound to 127.0.0.1:6050
, but all requests should go to https://sub.example.tld/
.
To summarize, posting a new user to http://localhost:6050/entity/user?_format=hal_json
, with the appropriate X-CSRF-Token
and Content-Type
headers set, works. It returns 200.
Posting to https://sub.example.tld/entity/user?_format=hal_json
, with the appropriate X-CSRF-Token
and Content-Type
headers set, does not. It returns 422 Unprocessable Entity.
{"message":"Type https:\/\/sub.example.tld\/rest\/type\/user\/user?_format=hal_json does not correspond to an entity on this site."}
In the recent log messages, I see:
Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException: Type http://sub.example.tld/rest/type/user/user?_format=hal_json does not correspond to an entity on this site. in Drupal\rest\RequestHandler->deserialize() (line 201 of /var/www/html/web/core/modules/rest/src/RequestHandler.php).
I do manually set the user's "_links" array:
"_links": {
"type": {
"href": "https://sub.example.tld/rest/type/user/user?_format=hal_json"
}
},
I know that authentication isn't the issue. My code is successfully accessing views that require authentication.
Since I think it might be something to do with these settings, I do have the following set:
$settings['trusted_host_patterns'] = ["$sub\.example\.tld$"]
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ["internal network ip","172.18.0.1","127.0.0.1"];
I'm running Drupal 8.7.3.
My docker image is based on php:7.1-apache.
Any ideas what I'm doing wrong?