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
Hello, I’m Allie!
So, first, do you have a Cloudflare account yet?
Schrodinger
SchrodingerOP3y ago
I do
Hello, I’m Allie!
Have you added your domain to it yet?
Schrodinger
SchrodingerOP3y ago
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?
Hello, I’m Allie!
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.
Schrodinger
SchrodingerOP3y ago
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 🥲
Hello, I’m Allie!
Do you have anything on the domain already you want to keep, or are you ok with starting with a clean slate?
Schrodinger
SchrodingerOP3y ago
I have an A record set up to another project i was working on. I would like to keep that
Hello, I’m Allie!
There should be a continue/import button. Click that to move on.
Schrodinger
SchrodingerOP3y ago
Okay. And after that the nameservers right?
Hello, I’m Allie!
Yup. Replace the pre-existing ones in Google with the ones you got from Cloudflare.
Schrodinger
SchrodingerOP3y ago
I did that as well. What next?
Hello, I’m Allie!
There should be another blue continue button, or something similar. Click that.
Schrodinger
SchrodingerOP3y ago
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
Hello, I’m Allie!
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!
Schrodinger
SchrodingerOP3y ago
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
Hello, I’m Allie!
Start by running cloudflared tunnel create <Name>
Schrodinger
SchrodingerOP3y ago
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
Hello, I’m Allie!
The config file should be called ~/.cloudflared/config.yaml
Schrodinger
SchrodingerOP3y ago
okay @HardAtWork I have created the config and ran the route dns command. I am getting this error when visiting the address
Schrodinger
SchrodingerOP3y ago
No description
Schrodinger
SchrodingerOP3y ago
oh i forgot to cover up the domain im working with lol. it's fine
Hello, I’m Allie!
Sometimes it takes a few minutes for the tunnel to start resolving. Have you started the tunnel yet?
Schrodinger
SchrodingerOP3y ago
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
Schrodinger
SchrodingerOP3y ago
i have set up everything in this. How do i start a tunnel now?
sc start cloudflared tunnel run

SERVICE_NAME: cloudflared
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 221732
FLAGS :
sc start cloudflared tunnel run

SERVICE_NAME: cloudflared
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 221732
FLAGS :
The service has started
tunnel: 909cd8f7-9539-4b08-b248-2466bb1ffef3
credentials-file: C:\Users\ajilp\.cloudflared\909cd8f7-9539-4b08-b248-2466bb1ffef3.json
ingress:
- hostname: server.ajilpappachan.com
service: http://localhost:8000
- service: http_status:404
logfile: C:\Users\ajilp\.cloudflared\cloudflared.log
tunnel: 909cd8f7-9539-4b08-b248-2466bb1ffef3
credentials-file: C:\Users\ajilp\.cloudflared\909cd8f7-9539-4b08-b248-2466bb1ffef3.json
ingress:
- hostname: server.ajilpappachan.com
service: http://localhost:8000
- service: http_status:404
logfile: C:\Users\ajilp\.cloudflared\cloudflared.log
This is the config file
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Schrodinger
SchrodingerOP3y ago
@HardAtWork sorry to bother you again 🥺
Hello, I’m Allie!
Is the tunnel not running now?
Schrodinger
SchrodingerOP3y ago
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
Hello, I’m Allie!
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?
Schrodinger
SchrodingerOP3y ago
sc start cloudflared tunnel run
[SC] StartService FAILED 1056:

An instance of the service is already running.
sc start cloudflared tunnel run
[SC] StartService FAILED 1056:

An instance of the service is already running.
I am trying to restart but i am getting this error. how do i stop the currently running service? @HardAtWork
Erisa
Erisa3y ago
What does the log file say?
Hello, I’m Allie!
Stop-Service -name “cloudflared”
Erisa
Erisa3y ago
or sc stop cloudflared
Schrodinger
SchrodingerOP3y ago
tried restarting but still getting error 1033
Schrodinger
SchrodingerOP3y ago
No description
Erisa
Erisa3y ago
What's in the log file? And you need to force refresh (Ctrl+F5) to refresh that error, it likes to cache it sometimes
Schrodinger
SchrodingerOP3y ago
log file is empty
Erisa
Erisa3y ago
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
Schrodinger
SchrodingerOP3y ago
this is the config file at that location
Erisa
Erisa3y ago
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 says
Schrodinger
SchrodingerOP3y ago
E:\Resources\cloudflared.exe --config=C:\Windows\System32\config\systemprofile\.cloudflared\config.yaml tunnel run
E:\Resources\cloudflared.exe --config=C:\Windows\System32\config\systemprofile\.cloudflared\config.yaml tunnel run
Erisa
Erisa3y ago
So 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
Schrodinger
SchrodingerOP3y ago
let me try i needed to add the tunnel name at the end but it works but now im getting a 502 error
Schrodinger
SchrodingerOP3y ago
No description
Schrodinger
SchrodingerOP3y ago
@Erisa | Out of office
Erisa
Erisa3y ago
Okay and what is in the log file?
Schrodinger
SchrodingerOP3y ago
2022-02-25T17:08:53Z ERR error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it." cfRay=6e3289bc18b087ba-SIN originService=http://localhost:8080
2022-02-25T17:08:57Z ERR error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it." cfRay=6e3289d6bb3c87ba-SIN originService=http://localhost:8080
2022-02-25T17:08:53Z ERR error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it." cfRay=6e3289bc18b087ba-SIN originService=http://localhost:8080
2022-02-25T17:08:57Z ERR error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it." cfRay=6e3289d6bb3c87ba-SIN originService=http://localhost:8080
this is showing in the console let me check the log file
Erisa
Erisa3y ago
localhost:8080 is the default when the config isnt present or is incorrect
Schrodinger
SchrodingerOP3y ago
this is the config file. is there something wrong?
Erisa
Erisa3y ago
no it seems fine - can you show the full output from the command? theres nothing sensitive in it
Erisa
Erisa3y ago
hm, and youre sure your file in that dir is config.yaml and not .yml or something?
No description
Schrodinger
SchrodingerOP3y ago
it is yaml. it was wrong in the registry at first. i changed it to yaml @Erisa | Out of office
Erisa
Erisa3y ago
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?
Schrodinger
SchrodingerOP3y ago
yes. if I don't use cmd as admin i get an access denied error
Erisa
Erisa3y ago
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
Schrodinger
SchrodingerOP3y ago
that logfile is still showing empty. so yeah it looks like the config file is not being read?
Erisa
Erisa3y ago
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, ha
Schrodinger
SchrodingerOP3y ago
no that makes sense lol any clue how to check why the config is not being read?
Erisa
Erisa3y ago
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 FacePalm2 would recommend moving the config file to a more accessible location like your user folder and trying to invoke it with that path
Erisa
Erisa3y ago
im using C:\Users\Erisa\config.yml to test and even did the command shorthand and it works
No description
Schrodinger
SchrodingerOP3y ago
wait so you don't actually need the config and cert files to be in the system folder to run as a service?
Erisa
Erisa3y ago
its the recommended way right now we are debugging an issue with manually ran commands, rather than a service
Schrodinger
SchrodingerOP3y ago
okay then let me try doing it in my users folder
Erisa
Erisa3y ago
(so the thread name makes more sense later to others looking at the archived thread list)
Schrodinger
SchrodingerOP3y ago
yes that worked @Erisa | Out of office
Erisa
Erisa3y ago
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
Schrodinger
SchrodingerOP3y ago
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?
Erisa
Erisa3y ago
Yeah, it runs in the background even when youre not logged in to Windows and will always start on boot if configured as "Automatic"
Schrodinger
SchrodingerOP3y ago
tunnel: 909cd8f7-9539-4b08-b248-2466bb1ffef3
credentials-file: C:\Windows\System32\config\systemprofile\.cloudflared\909cd8f7-9539-4b08-b248-2466bb1ffef3.json
ingress:
- hostname: server.ajilpappachan.com
service: http://localhost:8000
- service: http_status:404
logfile: C:\Windows\System32\config\systemprofile\.cloudflared\cloudflared.log
tunnel: 909cd8f7-9539-4b08-b248-2466bb1ffef3
credentials-file: C:\Windows\System32\config\systemprofile\.cloudflared\909cd8f7-9539-4b08-b248-2466bb1ffef3.json
ingress:
- hostname: server.ajilpappachan.com
service: http://localhost:8000
- service: http_status:404
logfile: C:\Windows\System32\config\systemprofile\.cloudflared\cloudflared.log
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?
Erisa
Erisa3y ago
run sc config cloudflared start=auto at this point id recommend trying it with all the files in your user folder
Schrodinger
SchrodingerOP3y ago
it 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?
Erisa
Erisa3y ago
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.
Schrodinger
SchrodingerOP3y ago
i ran the start command. but going to the site shows a blank screen and a 503 error
Schrodinger
SchrodingerOP3y ago
No description
Erisa
Erisa3y ago
Check the log file you configured?
Schrodinger
SchrodingerOP3y ago
using the start command is not writing to the log file?
E:\Resources\cloudflared.exe --config=C:\Users\ajilp\config.yaml tunnel run server
E:\Resources\cloudflared.exe --config=C:\Users\ajilp\config.yaml tunnel run server
This is the registry entry
No description
Schrodinger
SchrodingerOP3y ago
@Erisa | Out of office
Erisa
Erisa3y ago
Thats so annoying then, because it should
Schrodinger
SchrodingerOP3y ago
pain what should i do now? TT
Schrodinger
SchrodingerOP3y ago
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
No description
Erisa
Erisa3y ago
That would happen if the service is exiting immediately, which essentially means its broken and not actually running
Schrodinger
SchrodingerOP3y ago
@Erisa | Out of office It's fixed lol that was my mistake. i got the path to the config file wrong in the registry
Erisa
Erisa3y ago
oh, yeah that would do that
Schrodinger
SchrodingerOP3y ago
the service is working now lol yes it would thank you so much
Erisa
Erisa3y ago
neat, it should now run in the bg always even if youre not logged in to windows, which is always nice
Schrodinger
SchrodingerOP3y ago
so if i use pm2 to keep the node server running as a process the server will be online right?
Erisa
Erisa3y ago
as long as the node server is running, it will be accessible cos cloudflared will now run always
Schrodinger
SchrodingerOP3y ago
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.
Erisa
Erisa3y ago
What error are you getting with it? Is the domain added to your Cloudflare account?
Schrodinger
SchrodingerOP3y ago
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
No description
Schrodinger
SchrodingerOP3y ago
No description
Schrodinger
SchrodingerOP3y ago
@Erisa | Out of office
Erisa
Erisa3y ago
What is coconut? For the _domainconnect, you should disable the Proxy for it
Schrodinger
SchrodingerOP3y ago
This is the record from google domains
No description
Erisa
Erisa3y ago
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
Schrodinger
SchrodingerOP3y ago
oh okay thanks i think i can just recreate the record in cloudflared
Erisa
Erisa3y ago
It tells google that you own the domain.... somehow. I don't really know, but just set it to Unproxied and leave it
Schrodinger
SchrodingerOP3y ago
okay thank you so much. sorry for bothering you again
Want results from more Discord servers?
Add your server