Solved

Virtual server aliases

Posted on 1998-03-09
15
188 Views
Last Modified: 2013-12-25
For example, domain www.swcr.com is a virtual domain, hosted by ISP Xmission, so
pages http://www.xmission.com/~syswest/Home.html
and http://www.swcr.com/Home.html
are actually the same files. Is it possible to know somehow, that two URS lead us to the same point ?
By the way, if we open connection to www.swcr.com
...
struct hostent *hp;
...
hp = gethostbyname(...)
and try to search in
hp->h_aliases, it does not work..
Thanks in advance...
0
Comment
Question by:trof
  • 7
  • 4
  • 4
15 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1832109
With CGI? could you tell how a similar information relates to CGI programs?

...just wandering if there's some different way to reach your final goal.
0
 
LVL 1

Author Comment

by:trof
ID: 1832110
My CGI has to pull pages to process them and I don't want to process the same page twice..
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832111
I see... why not just translate each domain name into the corrensponding IP address, and keep track of the IP addresses already processed? Furthermore, you could also associate ports to IPs, in case there are different web servers on different ports on the same machine.

BTW, your code cannot work because you have no access to someone else's alias configuration.

What kind of help could i give?

0
 
LVL 2

Expert Comment

by:eckspurt
ID: 1832112
You can ensure that pages only get served once by setting up the configuration for one of those virtual servers to issue a redirect pointing at the other one.  If someone tries to go to http://www.xmission.com/~syswest/Home.html, they'd wind up actually loading http://www.swcr.com/Home.html.  That's the best approach you can take, since a URL is itself a unique identifier.  Virtual hosting gives the different server names different IP addresses, making it so that to all outside appearances, they're truly two different sites.

0
 
LVL 1

Author Comment

by:trof
ID: 1832113
I can not setup any configuration. I'm asking about not my virtual server, but about two abstract URL, pointed onto the same page... Is it really impossible to detect so ?
0
 
LVL 2

Expert Comment

by:eckspurt
ID: 1832114
Okay, so you need to come up with something out of the ordinary.  Exactly which kind of access do you want to affect?  Are you trying to make it so that any browser which accesses first one page and then the other will fetch the first one from cache?
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832115
Ok, i won't submit this as an answer because you are offering 250 points and i've no time to support you as needed; but, the answer remains the same: resolve IP addresses and work with them, there's no other way (and, BTW, what's so hard with this one?)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:trof
ID: 1832116
Ok,
julio says, I should just work on IP address level, and
eckspurt says, virtual servers have different IP addreses, and it does not work... So, tell me again, what should I do ?
PS: and please, _answer_, don't add comments, I don't want to keep these 250 points.. :-)
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832117
No, no.

I'm not telling you to work at  IP layer level; what you have to do is "resolve host domain names to their corrensponding IP addresses" (the well known dotted format: xxx.xxx.xxx.xxx).

Virtual server aliases DO share the same IP; actually, creating virtual servers is a way to give more than one name to a single IP address.

I strongly suggest you delete this question and repost it to the Unix/Networks topic area.
You won't get any good advice from strictly CGI experts.
0
 
LVL 2

Accepted Solution

by:
eckspurt earned 250 total points
ID: 1832118
You also won't find strictly CGI experts responding.  I'm a Unix sysadmin.

I'd hoped not to complicate the issue with DNS-only virtual servers, since it seems like the goal requires an IP-specific solution.  Yes, you *can* have "virtual" servers which respond to different domain names on the same IP address, but browsers are not required to specify the domain name of the page they're requesting, so that type of virtual server isn't useful as a public site.

www.swcr.com is at 204.228.141.42
www.xmission.com is at 198.60.22.9 and 198.60.22.4 (presumably rotated for better reliability)

Your CGI script can look in the environment passed to it by the server to determine which way the user connected to it.  See the  SERVER_NAME environment variable.

A description of the CGI spec that relates to this is at http://hoohoo.ncsa.uiuc.edu/cgi/env.html

0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832119
eckspurt: i guess you still don't get the point.

The CGI in question is ITSELF trying to establish a connection to other web servers (through sockets); trof is looking for a way to handle virtual servers in order to have its CGI not request outside pages more than once.

I'll give you a real-life example:

say i want to put a search engine on my site, but, someway, have not enough energy to set it up; i could just write a CGI which, itself, connects to Altavista, sends the given query, reads back results, reformats them depending on my own layout, sends back stolen information to the user.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832120
BTW, i am not a strict CGI expert, as well; i develop search engines on Digital AlphaServers, and make a living on it.
0
 
LVL 1

Author Comment

by:trof
ID: 1832121
SERVER_NAME is good enough.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1832122
SERVER_NAME not always works... but, good luck!

I spent 25 points to see *how* could you give away such a grade, and, points apart, make me waste time and energy.

EE is but a big knowledge-base container, and people like you help a lot making it unuseful.

But, nothing more than my humble opinion: i just couldn't resist.
0
 
LVL 2

Expert Comment

by:eckspurt
ID: 1832123
SERVER_NAME should always either contain the hostname or IP address of the server.  Otherwise it's a broken CGI implementation.

I'm glad that was the answer you're looking for, and happy you gave the answer a good grade, but you'd have gotten a quicker answer if you let on right away that you needed a pointer to the CGI documentation!

0

Featured Post

Google Storage: Standard vs. Nearline vs. Coldline

Google Cloud Storage has a number of classes to choose from. Although there are a lot in common, they vary in price and usage terms. This post explains Google Cloud Storage classes and helps to understand which  one to choose.

Join & Write a Comment

How to fix error ""Failed to validate the vCentre certificate. Either install or verify the certificate by using the vSphere Data Protection Configuration utility" when you are trying to connect to VDP instance from Vcenter.
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now