LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Perl or bash script to redirect traffic to another site. (https://www.linuxquestions.org/questions/linux-software-2/perl-or-bash-script-to-redirect-traffic-to-another-site-4175680360/)

Fred27377 08-13-2020 04:47 PM

Perl or bash script to redirect traffic to another site.
 
This would be great. I know somebody works with these scripts and uses them all the time. My problem is I don’t.

Thank you for reading!

TB0ne 08-13-2020 06:06 PM

Quote:

Originally Posted by Fred27377 (Post 6155616)
This would be great. I know somebody works with these scripts and uses them all the time. My problem is I don’t.

Thank you for reading!

You need to read the "Question Guidelines" link in my posting signature. Yes, there are MANY people who work with Perl and can write scripts. However, if you want one written FOR YOU, then you need to hire someone and pay them to do it. Otherwise, YOU need to show some efforts of your own. We are happy to help, but we aren't going to do your work for you.

Past that, you provide no details; version/distro of Linux, web server you're using, environment, and what your actual goal is. We can't guess.

berndbausch 08-13-2020 07:03 PM

Here is an answer, but since your question is remarkably vague, I can't tell whether it fits your case: https://www.linux.com/topic/networki...raffic-part-2/

This is how I found this answer: https://www.google.co.jp/search?q=ba...direct+traffic

Fred27377 08-14-2020 06:19 AM

TBOne - I hired a programmer from Fiverr. You know the site. He couldn’t do it. I’m looking for url forwarding example. I am not near the Perl scripting phase yet. I want to figure out how some one does it first. Facebook does it and bitly. Is this just a million CNAMES or is there as I suspect much more to it? I know you Can forward names with Apache. I’ve done that. So that’s two ways CNAMES and Apache. There’s also html.

Turbocapitalist 08-14-2020 07:51 AM

Please describe your task again, what you want to actually accomplish -- not how but what.

What kind of traffic do you wish to redirect TCP, UDP, etc? Or are you looking above the networking layer at the application layer, HTTPS, SSH, SIP, RTSP, etc?

TB0ne 08-14-2020 08:13 AM

Quote:

Originally Posted by Fred27377 (Post 6155771)
TBOne - I hired a programmer from Fiverr. You know the site. He couldn’t do it.

Shocked I am not.
Quote:

I’m looking for url forwarding example. I am not near the Perl scripting phase yet. I want to figure out how some one does it first. Facebook does it and bitly. Is this just a million CNAMES or is there as I suspect much more to it? I know you Can forward names with Apache. I’ve done that. So that’s two ways CNAMES and Apache. There’s also html.
Again, as asked several times now; WHAT ARE YOU TRYING TO ACCOMPLISH??? You have STILL provided no details about your system, or why exactly you can't do what you need through Apache or html, as you say you already know. Again, you need to do basic research and show your own efforts...putting "perl script url forwarding" into Google pulls up a LOT, including many examples and sample code. Not sure what more you need.

AGAIN: unless you provide details and answer questions, there is nothing we can do to help you.

boughtonp 08-14-2020 08:25 AM


 
There are numerous different ways to redirect traffic that vary from a single-line of code/config to installing dedicated switch/firewall appliances with fancy management interfaces.

You almost certainly don't need the latter, but it's not possible to say whether your issue can be solved with a single line because you've still not described what your actual issue is.

* Do you want all traffic from domain1 sent to domain2 or only some of it?
* Does the user need to know they're going to domain2 or does it not matter?
* Are both sites hosted on the same server or different servers?
* What (if any) server software is installed on the machine hosting domain1?
* What level of access/control do you have to that server?
etc

Changing DNS might be an option, but depends on domain2's servers accepting the request for domain1 - a CNAME is just an alias; it doesn't actually redirect - and of course you need control of the DNS records, and there's the propagation delay (can be 20 minutes, can be 48 hours).

Apache has at least four different ways of doing it, depending on the specific needs involved.

A HTML meta refresh is a low skill / low effort solution that may well be perfectly good enough for your needs, but you need to say precisely what those are.

If the website is written in Perl or Bash then they could generate the meta tag, or a HTTP 3xx response, or even act as a reverse proxy - but only if there are conditions involved (e.g. database lookup) that can't be addressed by the front-end server (i.e. Apache), because there's no need to re-write functionality that already exists and is well tested.


dc.901 08-14-2020 08:54 AM

Quote:

Originally Posted by Fred27377 (Post 6155616)
This would be great. I know somebody works with these scripts and uses them all the time. My problem is I don’t.

Thank you for reading!

If you have Apache web server, then you can also do something like this:
https://httpd.apache.org/docs/2.4/re...remapping.html

Fred27377 08-14-2020 12:09 PM

Thank you for the Apache site. I use some of this in my site already. The challenge is to create 1000 sub domains that all resolve. This would be like BITLY.com or Facebook. I’m sure these sites are also registrars. I just have to put my toe in the water if you get what I mean?

TB0ne 08-14-2020 12:42 PM

Quote:

Originally Posted by Fred27377 (Post 6155874)
Thank you for the Apache site. I use some of this in my site already. The challenge is to create 1000 sub domains that all resolve. This would be like BITLY.com or Facebook. I’m sure these sites are also registrars. I just have to put my toe in the water if you get what I mean?

Nope, still don't. And if you're trying to run a large-scale site and you're wanting to do redirects like that, good luck.
Quote:

Originally Posted by Fred27377
If you need to host a site on virtual server. Hit me up no cost and have fun.

If you have no idea how to do a redirect or write a script, why on earth would I want to host a server with you? You've still not answered ANY questions we've asked about your issue, so I'm presuming that communications with you regarding a hosted server would be in a similar vein.

If you're not going to answer questions that are asked of you, why bother posting a question??? You've STILL not provided any details, despite being asked numerous times thus far.

Fred27377 08-14-2020 02:47 PM

Thank you for caring! How about this. Create a Perl script with a 1000 numbers generated 1 through 1000. Append the host with these numbers in a file. Use Perl cgi to add these to a perlcgi webpage. Generate a 1000 HTML pages with a file label in sequence.

This would work because you could use 1000 of the same page of HTML.

Better?

TB0ne 08-14-2020 02:57 PM

Quote:

Originally Posted by Fred27377 (Post 6155924)
Thank you for caring! How about this. Create a Perl script with a 1000 numbers generated 1 through 1000. Append the host with these numbers in a file. Use Perl cgi to add these to a perlcgi webpage. Generate a 1000 HTML pages with a file label in sequence.

This would work because you could use 1000 of the same page of HTML. Better?

Nope...mainly because you still haven't shown any effort of your own, at all.

AGAIN, we are NOT going to write your scripts for you, period. You have been given direction and hints. You **STILL** do not answer questions asked or provide any details. You have been told this before:
https://www.linuxquestions.org/quest...es-4175676771/

Asking for handouts won't get you far.

dugan 08-14-2020 03:15 PM

Quote:

Originally Posted by Fred27377 (Post 6155771)
I’m looking for url forwarding example. I am not near the Perl scripting phase yet. I want to figure out how some one does it first. Facebook does it and bitly.

I have no idea what you're trying to set up, but if you just want to know how to write something like bit.ly, well, this was my first hit:

How to write a reverse-proxy with Go in 25 minutes

This is something the Fiverrr guy should have been able to give you. Unless he was dealing with a common cause of project failure. Which is unclear requirements. ;)

Maybe give us a simplified example where you show us two subdomains and a URL, and tell us how how want the redirection to work?

Fred27377 08-14-2020 04:35 PM

Alright thank you Dugan. Let’s go again. Maybe the reverse proxy is a better idea. You get a request and generate a blank webpage. You would have to assign page name url and HTML or xml. I liked the GO video. Seemed possible and on demand. I will look for examples. Thank you.

Fred27377 08-15-2020 05:45 AM

Perl pseudo code :

While loop
Sed >> list1
Next

While
List1 > touch > final dir

It’s possible in under a page!


All times are GMT -5. The time now is 03:22 PM.