-2

I bought a VPS Host that gave me only 1 IP Address which I used on my first domain name and it works without any problems.

Now my second domain name I can't use the same ip address as it points to the first domain name.

So I figured my only option was to use a GoDaddy hosted iframe redirection which redirects to a sub folder on my first domain which worked so far.

Now I'm trying to load paypal from <?php headers() ?> and I get a permission error because of that iframe

Refused to display 'https://www.paypal.com/cgi-bin/webscr?notify_url=&cmd=_cart&upload=1&business=removed&address_override=1' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

How do I avoid the Iframe solution for my second domain while not messing up my first domain?

Somebody I forgot once told me it doesn't matter if you have 1 IP Address you could host multiple websites on it? how it that possible the DNS doesn't seem to work off ports afaik, yes I could host multiple websites on different folders but that's not what I call hosting a real website it has to be pointed by a domain name, so this iframe issue doesn't happen

My server configuration is httpd (apache) that comes with CentOS 6 (Linux) operating system

SSpoke
  • 161
  • 1
  • 10
  • 4
    Voting to close - you miss basic knowledge. For example the fact that you can run multiple sites on one IP since - http 1.1 was around 20 years ago thanks to every request transmitting the domain name. That is basic knowledge - time to read the documentation. – TomTom May 27 '14 at 09:26
  • You don't understand how can I run multiple websites pointing on different domains? I tried everything I can't find any answers I did my research only thing I found was iframe redirection by GoDaddy and that's not good. – SSpoke May 27 '14 at 09:27
  • Host header separation - depends on which web server you use. It is in every howto. Try including google on your research with so arcane questions like "multiple websites on one ip". – TomTom May 27 '14 at 09:28
  • You mean like my domain name can request itself as a folder or something? how can i set this up Can you give me a good link to this – SSpoke May 27 '14 at 09:28
  • 1
    Start with google. Tons of tutorials around. I even did the work for you to find a good search term. Was only a second. – TomTom May 27 '14 at 09:29
  • Basically: every request to your webserver includes a `Host` header, which tells you which domain name is wanted. Your webserver should read that and serve the appropriate site. *How* this works depends on your server configuration, which you haven't told us, and in any case is fairly basic. – TRiG May 27 '14 at 09:29
  • @TRiG my server configuration is a default httpd server apache? i guess that comes with CentOS I put my site in `var/www/html` – SSpoke May 27 '14 at 09:31
  • Okay I found this website http://serverfault.com/questions/106882/how-do-you-have-one-ip-address-and-many-websites seems like domain names can be made into a folder with extensions being subfolders but still doesn't explain how to enable this feature – SSpoke May 27 '14 at 09:36
  • ` DocumentRoot /www/example2 ServerName www.example.org # Other directives here ` Is this all I need? I thought the ServerName was something like `localhost` which doesn't mean anything. – SSpoke May 27 '14 at 09:39
  • The name of the technology you are looking for is 'Name Based Virtual Hosting'. We and the internet at large have lots of information about it. All you need to do now is search for it. – user9517 May 27 '14 at 09:49

1 Answers1

2

edit /etc/httpd/conf/httpd.conf, make sure you have "Listen 80" and "NameVirtualHost *:80" in it and add your vhosts. For example:

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     DocumentRoot /var/www/example.com/public_html
     ServerName www.example.com
     ServerAlias example.com
     ErrorLog /var/www/example.com/error.log
     CustomLog /var/www/example.com/access.log common
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin webmaster@site2.com
     DocumentRoot /var/www/site2.com/public_html
     ServerName www.site2.com
     ServerAlias site2.com
     ErrorLog /var/www/site2.com/error.log
     CustomLog /var/www/site2.com/access.log common
 </VirtualHost>

<VirtualHost ipaddress:443>
     ServerAdmin webmaster@site2.com
     DocumentRoot /var/www/site2.com/public_html
     ServerName www.site2.com
     ServerAlias site2.com
     ErrorLog /var/www/site2.com/sslerror.log
     CustomLog /var/www/site2.com/sslrequests.log

     SSLProxyEngine on
     SSLEngine on
     SSLCertificateFile /etc/ssl/certs/server.crt
     SSLCertificateKeyFile /etc/ssl/private/server.key
</VirtualHost>

So under your /var/www/ you should have 2 folders example.com and site2.com which are owned by your http deamon.

You better do some research on how to use vhosts as this is a very basic question which doesn't belong here.

Basil
  • 8,811
  • 3
  • 37
  • 73
timmeyh
  • 958
  • 1
  • 6
  • 25
  • I'll try it out when my DNS gets refreshed in 48 hours hopefully it will work to me I never understood this I thought it worked by IP Addresses and the `HOST:` in the HTTP request packet was just for security. – SSpoke May 27 '14 at 09:44
  • you might want to setup a default entry when someone surfs your IP aswell. – Dennis Nolte May 27 '14 at 09:47
  • You better lower your dns TTL then for future changes also you can monitor the dns propagation on: https://www.whatsmydns.net/ – timmeyh May 27 '14 at 09:47
  • nice website whatsmydns.net is that like a proxy website that goes to your domain from all over the world? how about my first webiste had mod_ssl enabled so I need to do `VirtualHost*:443` as well? – SSpoke May 27 '14 at 09:52
  • I've updated the post for the vhost with ssl. – timmeyh May 27 '14 at 11:08
  • nice organzingo f the folders atleast now my log files are with the html folders don't have to go to `var/log/httpd` every few months to clear those big files, although I found a good solution a few months back that only keeps like 2 weeks of log files the rest automatically is wiped. Also like to mention there is a SYNTAX error in your code but I found it using `service httpd configtest` the problem is with those `access_log`'s it requires 3 parameters but you only have 2. I'll update the post with what worked.. yeah now all my websites run on 1 IP address!!! and SSL works too.. – SSpoke May 27 '14 at 20:36
  • I had to edit `ssl.conf` inside `etc/httpd/conf.d` to get SSL to work. Editing SSL in httpd.conf caused a `[warn]` error about port 443 – SSpoke May 27 '14 at 20:38