dumduckie - Setting Up Tunnels
i need a persistent tunnel. i am trying to make a sort of media backup server. i can't seem to get ddns to work. i think my router doesn't support http traffic
101 Replies
So, first, do you have a Cloudflare account yet?
I do
Have you added your domain to it yet?
I tried. But I'm not sure how to. I typed in my domain and it showed an A record i had set up pointing to another project. Should I remove that? What other record should I add? Can I keep it empty?
That is showing what records currently exist on your domain. This is probably a previous project you set up through Google, or something that Google may have added on its own. It is up to you whether you want to keep the record or not. Just make sure you won’t break anything if you do choose to remove it.
Is it okay to keep the records empty? Suppose i own the domain example.com. And i want the tunnel to be accessible through something like subdomain.example.com. Can you walk me through the process of setting up something like that? Sending documentation resources is also fine. I'm just confused with the networking terms 🥲
Do you have anything on the domain already you want to keep, or are you ok with starting with a clean slate?
I have an A record set up to another project i was working on.
I would like to keep that
There should be a continue/import button. Click that to move on.
Okay. And after that the nameservers right?
Yup. Replace the pre-existing ones in Google with the ones you got from Cloudflare.
I did that as well. What next?
There should be another blue continue button, or something similar. Click that.
Oh i didn't see that. But I'll have to try it tomorrow now because it's late for me 🥲. Can I bother you tomorrow? Thank you so much for your help so far
Of course! Reply to a message I have sent in this thread, or send me a ping like so: @HardAtWork, and I’ll get back on. Have a nice evening!
Sure. Thank you so much. Have a good rest of the day.
@HardAtWork Hi sorry for the late response
i have completed setting up the site
i logged in to cloudflared from cmd but running the tunnel command still creates a temporary tunnel
Start by running cloudflared tunnel create <Name>
i have created the tunnel. i am trying to make the config file. what should the config file be called? I can't find that in the docs
@HardAtWork
The config file should be called ~/.cloudflared/config.yaml
okay
@HardAtWork I have created the config and ran the route dns command. I am getting this error when visiting the address
oh i forgot to cover up the domain im working with lol. it's fine
Sometimes it takes a few minutes for the tunnel to start resolving. Have you started the tunnel yet?
YES it worked oml thank you so much
i have one more question tho how do i make it persistent?
for instance if i am running the tunnel on a vps or a pi how can i keep it running after i stop ssh? like using pm2 for node apps?
@HardAtWork
i have set up everything in this. How do i start a tunnel now?
The service has started
This is the config file
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
@HardAtWork sorry to bother you again 🥺
Is the tunnel not running now?
i set up the service like it says in this docs. but how do i actually start it? because going to the domain shows the same error as before. not found
If the service has started, then it should be working now.
Hold on…
Hey @Erisa | Out of office, do you know what might be the issue here? If a cloudflared Windows Service is active, it should be resolving, right?
I am trying to restart but i am getting this error. how do i stop the currently running service?
@HardAtWork
What does the log file say?
Stop-Service -name “cloudflared”
or
sc stop cloudflared
tried restarting but still getting error 1033
What's in the log file?
And you need to force refresh (Ctrl+F5) to refresh that error, it likes to cache it sometimes
log file is empty
Okay, how did you configure the service? Is it set to the right config file?
by default i believe it uses
C:\Windows\System32\config\systemprofile\.cloudflared\config.yml
this is the config file at that location
But you can set it in registry
can you check in regedit? navigate to
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cloudflared
and see what imagepath
saysSo if you stop the service and then run that same command manually from a terminal to test, does it work then?
May have to run it as administrator mind you
let me try
i needed to add the tunnel name at the end but it works
but now im getting a 502 error
@Erisa | Out of office
Okay and what is in the log file?
this is showing in the console
let me check the log file
localhost:8080 is the default when the config isnt present or is incorrect
this is the config file. is there something wrong?
no it seems fine - can you show the full output from the command? theres nothing sensitive in it
hm, and youre sure your file in that dir is config.yaml and not .yml or something?
it is yaml. it was wrong in the registry at first. i changed it to yaml
@Erisa | Out of office
I tested the same thing on my system, it gives a different output and appears to work.
Only thing that makes sense is that it can't read that config file, because under
Settings
of the output it doesn't load in the credentials-file value like it does on mine.
Are you running that command as Administrator?yes. if I don't use cmd as admin i get an access denied error
Wow, thats super weird then
Not that I'm 100% sure it would help but can you try updating to the latest version of cloudflared and the same binary I have?
https://github.com/cloudflare/cloudflared/releases/download/2022.2.2/cloudflared-windows-amd64.exe
Yours is 1 version behind
that logfile is still showing empty. so yeah it looks like the config file is not being read?
Yeah. The config file is not being read.
If I make mine use the same config file but with a different ID (albeit not in the same location) then it works fine
Though, and this isnt related to it working really
Adding the
logfile:
thing caused the command output to become extremely verbose, since the normal log was sent to that file instead
Which make it 100% that your config file is not being read for whatever reason
Because you don't get that same verbose behaviour
Unless mine is being weird, hano that makes sense lol
any clue how to check why the config is not being read?
Unfortunately the way cloudflared works doesnt allow for much flexibility in that department, when the config file isnt read it doesnt like to say that and just uses default settings which is annoying would recommend moving the config file to a more accessible location like your user folder and trying to invoke it with that path
im using C:\Users\Erisa\config.yml to test and even did the command shorthand and it works
wait so you don't actually need the config and cert files to be in the system folder to run as a service?
its the recommended way
right now we are debugging an issue with manually ran commands, rather than a service
okay then let me try doing it in my users folder
(so the thread name makes more sense later to others looking at the archived thread list)
yes that worked @Erisa | Out of office
config file in user folder is working?
honestly i would just update the path on the service and leave it there, the benefits from putting it in the system32 folder are fairly minor
okay then i will just do that. that honestly seems more convenient for me anyway.
@Erisa | Out of office what is the purpose of adding to the registry? is it just to start the service on boot?
Yeah, it runs in the background even when youre not logged in to Windows and will always start on boot if configured as "Automatic"
I tried modifying the system config and ran the command again but still getting the 502 error
how do i configure as automatic?
and does it work from user folder?
run
sc config cloudflared start=auto
at this point id recommend trying it with all the files in your user folderit works with all the files in users folder. but do i have to run the service manually? and if i close the terminal the service stops? how do i make it persistent?
The thing in the registry is a "service" which runs in the background. Once you have the registry set to use the right config file and the contents of that file are correct, you can
sc start cloudflared
to run it in the background independently of your user session on Windows.
Assuming you've done sc config cloudflared start=auto
at least once, it will now also launch everytime you start the machine, meaning it will always be running in the background.i ran the start command. but going to the site shows a blank screen and a 503 error
Check the log file you configured?
using the start command is not writing to the log file?
This is the registry entry
@Erisa | Out of office
Thats so annoying then, because it should
pain
what should i do now? TT
is this supposed to be like this? I shouldn't be able to start the same service again if one is already running right? Why does it say there is no service running when im trying to stop? @Erisa | Out of office
That would happen if the service is exiting immediately, which essentially means its broken and not actually running
@Erisa | Out of office It's fixed lol that was my mistake. i got the path to the config file wrong in the registry
oh, yeah that would do that
the service is working now
lol yes it would
thank you so much
neat, it should now run in the bg always
even if youre not logged in to windows, which is always nice
so if i use pm2 to keep the node server running as a process the server will be online right?
as long as the node server is running, it will be accessible
cos cloudflared will now run always
sounds great. thank you so much. @Erisa | Out of office @HardAtWork
@Erisa | Out of office Hi sorry to bother you again. But I had another subdomain set up in google domains and then brought in that record to cloudflared when i set up the site. but that site is not working now.
What error are you getting with it? Is the domain added to your Cloudflare account?
These are the two records in cloudflared. the second one is the tunnel you helped me set up yesterday. the first one was imported from google when i set up the site. that one is not working
@Erisa | Out of office
What is coconut?
For the _domainconnect, you should disable the Proxy for it
This is the record from google domains
I'm not sure how to help with this since it seems unrelated to tunnel and I don't think I have enough information to understand what you're trying to do
Also I'm about to go to sleep
oh okay thanks
i think i can just recreate the record in cloudflared
It tells google that you own the domain.... somehow.
I don't really know, but just set it to Unproxied and leave it
okay thank you so much. sorry for bothering you again