I have a (mostly) headless WP project that is setup like so:
- WP Admin used for content management
- Front end React app that fetches data from GraphQL
- GraphQL server that communicates with WP Rest API (with some Redis in the middle)
On older version of Local, this wasn’t a problem because all WP host handling with inside Virtualbox but now I’m having a hard time getting GraphQL and Local to coexist.
If both are present in /etc/hosts
it causes a clash on the localhost IP (both servers are competing for 127.0.0.1
). I’ve been trying to adjust the NGINX settings in /Local Sites/site-name/conf/nginx/
but when I try something like this, it hasn’t helped, even after restarting nginx:
server {
listen 80;
listen [::]:80;
server_name apiurl.test;
location / {
proxy_pass localhost:4444;
}
}
Current Status
WIth hosts file like so:
127.0.0.1 apiurl.test
## Local by Flywheel - Start ##
::1 wpsite.test #Local Site
127.0.0.1 wpsite.test #Local Site
I can access GraphQL at http://apiurl.test:4444/graphql
but I cannot access WordPress admin or front end; Local shows a red banner with a port conflict error.
If I remove the apiurl.test
line from hosts file and turn off the GraphQL server, I can access WordPress just fine.
Goals
- Have a custom domain for local API
- I’s okay if it has to have explicit port numbers, so
apiurl.test
orapiurl.test:4444
would be a success
- I’s okay if it has to have explicit port numbers, so
- Have custom domain for multisite WordPress install
- Be able to access each of them via HTTP
I suspect the solution lies in configuring Local’s NGINX conf in a certain way. Does anyone have some guidance or suggestions to test drive?
Thanks!