T
Twenty9mo ago
paulyili

Setting up URL/Domain

I get a little stuck on this. in the .env there's the:
SERVER_URL=https//lcoalhost:3000
# FRONT_BASE_URL=http://lcoalhost:3000
SERVER_URL=https//lcoalhost:3000
# FRONT_BASE_URL=http://lcoalhost:3000
If i have nginx proxy manager pointing crm.mydomain.com to port 3000. all the methods i try, each time i try to use crm.mydomain.com, i get the same "Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure resource '<URL>'. This request has been blocked; the content must be served over HTTPS." what would be the correct method insetting up the URLs in the .env? running on docker on ubuntu server. i used the "One Command" method to install it. which is great.
30 Replies
charles
charles9mo ago
the issue is that your frontend is served over https but your backend is served over http ; your browser considers this as a security flax (and it is right!) You need to serve your backend over https. To do that you can either use a certificate manager such as let's encrypt or use another service that can generate ssl for you (such as cloudflare or cloudfront)
paulyili
paulyiliOP9mo ago
ahh i figured that was the case. previously i had both behind it's own nginx and had forwarded the nginx ip to my nginx proxy manager.
i felt like that was a good way do didn't need to manage SSls
charles
charles9mo ago
you should be able to do the same here!
paulyili
paulyiliOP9mo ago
99% sure i got it working using nginx. no errors are showing up. Is the email sync working? i can't seem to get my emails to sync. i can SSO and i can add the email account (multiple) with no issues.
charles
charles9mo ago
do you have your worker running? yarn worker:prod? sorry this part is BADLY documented (when I say badly, is inexistent, it will be one of our April priority)
paulyili
paulyiliOP9mo ago
that's okay. it's still early days. Im mostly just testing and experimenting. workers are running. i ran yarn worker:prod and everything is initalised.
paulyili
paulyiliOP9mo ago
but when i click "email settings" i get this error (screen shot)
No description
charles
charles9mo ago
@Weiko @Raphaël for you!
Weiko
Weiko9mo ago
Hi @paulyili this error is unrelated to the sync, I can reproduce it on main though (cc @Raphaël), thank you I will create a ticket. For the sync to work you will need to run some crons that will enqueue jobs in your queue. You will need to run
yarn command:prod cron:messaging:gmail-partial-sync
yarn command:prod cron:messaging:gmail-fetch-messages-from-cache
yarn command:prod cron:messaging:gmail-partial-sync
yarn command:prod cron:messaging:gmail-fetch-messages-from-cache
However, even without the queue, a first sync should have been executed (what we call "full-sync") already and you should see some emails in your message table (and even some contact automatically created). Let me know if that's not the case Then gmail-partial-sync will take care of syncing your emails, you can adjust the cron pattern before executing the command above, in packages/twenty-server/src/modules/messaging/commands/crons/patterns/fetch-all-workspaces-messages.cron.pattern.ts (which is actually a bad name...). It will first query gmail and store all the new email ids in a cache. The second cron will take care of scanning the cache and fetch the content of those emails if the cache is not empty, this one should be executed right after.
paulyili
paulyiliOP9mo ago
Hi Weiko, This is what i've noticed. in 0.3.3 it would sync my gmail and add all gmail contacts in the CRM and sync all emails in 0.3.4 it would only sync the emails. not add any contacts. in 0.4.0 it wont do either. I tried to run those 2 commands with no luck. this with the self hosted docker FYI.
Weiko
Weiko9mo ago
Few things to check: - If you are self-hosting, you need to make sure that your workspace has "active" in the subscriptionStatus, we should probably change that for self-hosting since it does not make much sense but currently we check that value when we run the cron. - As I've described above, a cache is involved and if you don't use redis it will be in-memory which means after each refresh/reload of the server (so even code change will trigger it) it will probably reset that cache and messages that are waiting to be imported will be lost with the cache, that could explain the issue 🤔 - In 0.3.4 we moved contact creation outside of the message import logic to delegate it through a listener and its dedicated job, however the logic shouldn't have changed so as long as your contact emails do not match with those email providers packages/twenty-server/src/utils/email-providers.ts it should correctly create people/companies and assign them (personId within the messageParticipant table)
paulyili
paulyiliOP9mo ago
@Weiko how do i check the subscription status? i installed redis and i connected twenty to it. it connected no problem. when i try log in or create an accoung i get this in the logs(i've changed the names and id for secury reasons) as soon as disconnect from redis, there's no errors.
Exception Captured
{
user: {
id: '11111111-2222-3333-4444-555555555555',
firstName: 'Paul',
lastName: 'Lastname',
workspaceId: '12345567-1234-1234-1234-123456789098',
workspaceDisplayName: 'MyCompany'
}
}
[ [ErrorReply: ERR value is not an integer or out of range] ]
Exception Captured
Exception Captured
{
user: {
id: '11111111-2222-3333-4444-555555555555',
firstName: 'Paul',
lastName: 'Lastname',
workspaceId: '12345567-1234-1234-1234-123456789098',
workspaceDisplayName: 'MyCompany'
}
}
[ [ErrorReply: ERR value is not an integer or out of range] ]
Exception Captured
Weiko
Weiko9mo ago
Subscription status is inside core.workspace table. For your Redis error, that's weird. Does it only happen when you try to connect your google account in the settings? What's your redis version? We don't use any Redis command that expects an integer 🤔 Do you have the stackstrace?
paulyili
paulyiliOP9mo ago
will check the db shortly. redis version is 7.2.4. i just installed it using docker run --name my-redis -d -p 6379:6379 redis im not sure what stackstrace is. sorry im somewhat new to some of this,
Weiko
Weiko9mo ago
I've tried with 7.2.4 and can't reproduce your issue 🤔. Unfortunately the email sync won't work without Redis because we need to have a persistent cache shared between the worker and the main app which won't work with the in-memory cache. I've just created a ticket to integrate sqlite for the cache, should be much easier to use for self-hosting. Hopefully changing the subscriptionStatus will fix your issue
paulyili
paulyiliOP9mo ago
hmm i changed it to active, it's still the same. i tried with different emails using SSO and then i disabled SSO as it thought it may be the cause of something. but each time i connect redis, i get that same error. im using the blank/default workspace. all created from that "one command installation" i logged out then back in and i did see this "Error during useFindManyRecords for "activities", Response not successful: Received status code 500" and "Error: ApolloError: Response not successful: Received status code 500" i dont mind using redis, but i can't get to the bottom of this issue. SQlite would be a good alternative for those who just want to run and forget.
Weiko
Weiko9mo ago
"Error during useFindManyRecords for "activities", Response not successful: Received status code 500"
It's probably unrelated if it's affecting "activities", you should see the error message on your server to help you, probably a Gql schema issue 🤔
hmm i changed it to active, it's still the same.
Still [ErrorReply: ERR value is not an integer or out of range] ] ? Does it happen in your worker or your app?
im using the blank/default workspace. all created from that "one command installation"
Let me try a full setup with the command, I'll get back to you
paulyili
paulyiliOP9mo ago
that is in the docker container logs for twenty-server-1 I have it sitting open when i create the container. Everything is ok, as soon as i sign in, or do anything signed in, those are the errors on repeat. did you end up checking it out? the err value is solved. i had CACHE_STORAGE_TTL 3600 * 24 * 7 in the env like the example. i removed it and the error went away. then i added CACHE_STORAGE_TTL 3600 that worked so i left it. I've also set the subscription status to active for the users but the emails still wont show up.
charles
charles9mo ago
@Weiko FYI 🙂
Weiko
Weiko9mo ago
Yes I did, it worked on my side 🤔 Interesting, I'll try that on my side, maybe there is a bug with the current default value indeed, glad you managed to fix it!
Weiko
Weiko9mo ago
If you run the worker, do you see something like this
No description
Weiko
Weiko9mo ago
I ran node dist/src/command/command cron:messaging:gmail-fetch-messages-from-cache and node dist/src/command/command cron:messaging:gmail-partial-sync then yarn worker:prod Also if you can look at your redis to observe the queue that would help. I'm using RedisInsight (GUI)
Weiko
Weiko9mo ago
the first time you run the worker you should see some keys inside "bull", here you can see your queues. Important ones here are "messaging-queue" where you should only have 1 job if you did 1 connection (1 fullsync)
No description
Weiko
Weiko9mo ago
Then cron-queue where you will see your repeatable jobs, here you should see 2 inside repeats since we ran 2 cron commands That would confirm if it's correctly writing in the queue My .env looks like this
...
AUTH_GOOGLE_APIS_CALLBACK_URL=[TO_FILL]
MESSAGING_PROVIDER_GMAIL_ENABLED=true
AUTH_GOOGLE_CLIENT_ID=[TO_FILL]
AUTH_GOOGLE_CLIENT_SECRET=[TO_FILL]
CACHE_STORAGE_TYPE=redis
CACHE_STORAGE_TTL=3600
MESSAGE_QUEUE_TYPE=bull-mq
REDIS_HOST=host.docker.internal
REDIS_PORT=6379
...
...
AUTH_GOOGLE_APIS_CALLBACK_URL=[TO_FILL]
MESSAGING_PROVIDER_GMAIL_ENABLED=true
AUTH_GOOGLE_CLIENT_ID=[TO_FILL]
AUTH_GOOGLE_CLIENT_SECRET=[TO_FILL]
CACHE_STORAGE_TYPE=redis
CACHE_STORAGE_TTL=3600
MESSAGE_QUEUE_TYPE=bull-mq
REDIS_HOST=host.docker.internal
REDIS_PORT=6379
...
I'm assuming the [TO_FILL] is good on your side since you already did a full-sync
thilles
thilles9mo ago
Hi! Could you share the configs for using nginx proxy manager and lets encrypt?
paulyili
paulyiliOP9mo ago
Hi @thilles Ive uploaded my config, exactly how i have it set up. All you need to do is replace mydomain.com with yours. replace all the passwords and give redis an IP.
thilles
thilles9mo ago
Thanks! Much appreciated!
paulyili
paulyiliOP9mo ago
@thilles let me know how you go. Even thoughts on the whole setup. if it's worthey or with some changes, fell free to use it as a way of self hosting it. It defiantly would solve a lot of issues when people want to use Nnginx proxy manager to set the ip and port to a domain or subdomain.
thilles
thilles9mo ago
Had time to play with it somewhat now finally. I got it running, but had to add a redis service and the create the external network, after some trial and error. I´m at the point where I can connect to http://crm.mydomain.foo:3300 . Next step is to add https using lets encrypt 🔏

redis:
image: redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- twenty_frontend
restart: always
...
networks:
twenty_frontend: {}
nginx_proxied:
driver: bridge
external: true

redis:
image: redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- twenty_frontend
restart: always
...
networks:
twenty_frontend: {}
nginx_proxied:
driver: bridge
external: true
All in all definitively something other can have have use for as well!
paulyili
paulyiliOP9mo ago
Interesting, will have to try that. I just connected it to a separate redis server. ah yes forgot to mention, you have to create a new network manually. i dont encrypt it from there, i just point my main nginx which does all the reverse proxies to the twenty nginx. easier to manage.
Want results from more Discord servers?
Add your server