Has anyone successfully got this working on docker and Nginx?
I can get this running on docker with localhost. but nothing i do will make it work when using nginx reverse proxy.
in the console (chrome) i get
"index-O3h98bLs.js:132
POST https://192.168.1.195:3000/graphql net::ERR_SSL_PROTOCOL_ERROR"
then
"Uncaught (in promise) ApolloError: Failed to fetch"
If i remove my SSL, i get a CORS error.
Im all out of ideas but really keen on getting this running though the reverse proxy.
I've tried different settings on the. env file,
using IPs instead of localhost, pointed the database to the docker network or letting it configure itself.
have tried a few things in nginx but everything i've tried still gives me the same error.
30 Replies
As your front is server on an https route, your browser will require the XHR calls to be done over https too (otherwise you will get this CORS error). This means your must serve your server over https.
To serve your server in https, you'll need to configure your nginx to serve it over https.
Here is an example configuration:
https://gist.github.com/basharovV/e25989cc918f0b21ded26c8bf3be8400
Gist
How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Expr...
How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Express and Node - https_nginx_express_node_config.md
You can look into "let's encrypt" to generate your own ssl certificate if you don't have one for your domain
Alternatively you can also use a service such as cloudflare or cloudfront (aws) to handle the certificate for you but connect to your server in http behind the scene (this means it's not end-to-end encryption but this is generally acceptable)
Thsts odd. Because I am using let's encrypt with npm. I'm using nginx proxy manger (gui). Setting a ssl is quite easy (as I've done for other apps)
If i remove the SSL I get the CORS error.
this is what i get in chrome.
yep, your https is failing, it should be on your nginx config side, not sure where
Any recommendations?
its a very standard config in nginx proxy manager. (works for every other docker container i have running)
cache assets, block common exploits, WebSocket support.
SSL is just Let's encrypt.
Should i have a different url for each port?
i.g twenty.myurl.com & twentyapi.myurl.com?
does it need headers?
Im not to technical with NPM unfortunately.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
So for example .env file, the front end should point to localhost or the vm IP. And the backed should point to twenty-api.myurl.com ?
like this:
TAG=latest
PG_DATABASE_URL=postgres://twenty:twenty@twenty-db:5432/default
FRONT_BASE_URL=http://192.168.1.123:3001
LOCAL_SERVER_URL=http://twenty-api.myurl.com
ACCESS_TOKEN_SECRET=PASSWORD2
LOGIN_TOKEN_SECRET=PASSWORD3
REFRESH_TOKEN_SECRET=PASSWORD4
SIGN_IN_PREFILLED=false
POSTGRES_USER=postgres
POSTGRES_PASSWORD=PASSWORD1
POSTGRES_ADMIN_PASSWORD=PASSWORD1
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
yeah, so i have for example
twenty.mydomain.com > 192.168.1.123:3001
twenty-api.mydomain.com > 192.168.1.123:3000
both with websocket support & lets encrypt SSL.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Oh wow.
this is a little beyond my knowledge. little overwhelming so to speeak.
i understand what you've done,
are you willing to walk though this with me?
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Hello, I have the same problem could you please share your docker .env?
Actually, do you mind sharing an .env file?
I have all the containers running , but having trouble understanding the nginx configuration to get it talking to my nginx proxy manager.
The nginx configuration you have is set to port 80,
Do change this to the port I have my url is set to, in nginx proxy manager (gui) e.g crm.mydomain.com > 192.168.1.123:3300 ?
In the compose file, you have a variable for "port" which port is that for if using the default 3000 and 3001? Or is this the url port?
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
hmm, pretty much the same as my conf.
I've basically used your dockercompose. your .conf (filled out) and the twenty.conf which is in it's nginx folder. all in the twenty folder. all containers are running with no errors if i run that as is, with filled UUID & domain names. i have left port 80 on the docker-compose file and nginx. i've set my nginx proxy manager for my twenty.myurl.com to be on port 80 with the VM ip 192.168.1.123 for example. i get 502 error when i go to the url. that's where im stuck.
I've basically used your dockercompose. your .conf (filled out) and the twenty.conf which is in it's nginx folder. all in the twenty folder. all containers are running with no errors if i run that as is, with filled UUID & domain names. i have left port 80 on the docker-compose file and nginx. i've set my nginx proxy manager for my twenty.myurl.com to be on port 80 with the VM ip 192.168.1.123 for example. i get 502 error when i go to the url. that's where im stuck.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
i think that's from nginx proxy manager.
because if i try to ping 192.168.1.123:80 from my windows pc in powershell it fails.
i also just saw this in my browser console
crm.myurl.com/:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
okay i managed to get it to work,
i had to set the nginx ports to 3300:3300
weirdly, the first time i tried this, it gave me the same HTTPS error. now it actually worked. i must have changed something else.
what would the "server" url be if they're all being redirected to the same 3300 port for me as usually it's 3000 and 3001 ?
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
To get API to work i had to change the docker compose & twenty.conf
this allowd me to use crm-api.mydomain.com for the API which worked.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
What does the console tab show when you try load the page
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
hmm. if it's not throwing errors. like a HTTPS one and apolloerror. id try this.
sudo docker exec -it {your_backend_container} /bin/sh
yarn:databasereset
then exit
exit
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
I did that originally 🙂 but was
/api
but their playground wasn't accepting it for some odd reason. so i couldn't see any API endpoints i could use.@paulyili did you manage to get it working?
Yep, got it running properly
wonderful!