Unable to create URL with wampserver - web

I am trying to create a URL for a site hosted through wampserver, but no matter what I do I am unable to get the URL to work. The site is online because I am able to connect through the servers IP address, though.
(I should also mention that this site is only available on an intranet)
hosts file:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 www.socialclub.com #also tried public/private IP, still only works locally
vhosts.conf:
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "E:\Data\Users Apps\wamp\www\socialclub"
</VirtualHost>
<Directory "E:\Data\Users Apps\wamp\www\socialclub">
AllowOverride All
Order Allow,Deny
Allow from all
Options Indexes FollowSymLinks Includes ExecCGI
</Directory>
<VirtualHost *:80>
DocumentRoot "E:\Data\Users Apps\wamp\www\socialclub"
ServerName www.socialclub.com
</VirtualHost>
Every guide I've looked at says that this should work, but it only works locally. What do I need to do for the URL to work from other computers?

Ok I think the problem is your are not understanding what the HOSTS file is used for and what its scope is.
The HOSTS file only effects the single PC that it lives on. It is used to seed the windows DNS cache at boot time. So whatever you put in this file will have no effect on any other PC in your intranet.
There are a couple of solutions :
Lets assume your PC running WAMPServer has the ip address 192.168.1.10:
You could go to each PC in your intranet and make this change to the
HOSTS file on each PC
192.168.1.10 socialclub.com
people normally think this is too much hassle especially if they have more than 5-6 PC's to mod
You could install a local DNS Server, or make use of an existing
local DNS Server. Then as long as all the PC's in your intranet are
using that DNS Server you add the domain name to that DNS Server.
people normally think this is a good idea, but it can be quite complicated to get this right and not loose access to the real DNS servers out there on the web
A couple of changes I would suggest to your httpd-vhost.conf file
First leave localhost pointing to the original wampserver homepage, but only allow access from the PC running WAMPServer. The tools on the homepage can be a very useful for debug/diagnostics/etc, but only allow access to locahost from the PC running WAMPServer.
Second put the <Directory></Directory> block inside the Virtual Host definition. This allows you to make each virtual hosts security specific to that virtual host.
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:\Data\Users Apps\wamp\www\socialclub"
ServerName www.socialclub.com
<Directory "E:\Data\Users Apps\wamp\www\socialclub">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
# assuming your subnet equates to this range
# and you are using Apache 2.4.x
# its not necessary to allow access from all in an intranet
# in fact it might be dangerous
Require ip 192.168.1
</Directory>
</VirtualHost>

Related

iptables drop host domain not in list

I would like to block any traffic that does not come for the websites hosted on my VPC.
My Server's IP address is 1.2.3.4 which hosts 3 websites.
Following requests should be allowed:
http:// example1.com or https:// www.example1.com
http:// example2.com/ or https:// www.example2.com
http:// example3.com/ or https:// www.example3.com
Following requests should be blocked (including server's IP address):
http: //1.2.3.4/ or https:// 1.2.3.4/
http:// anyotherdomain.com/ or https:// anyotherdomain.com/
List of allowed Host names could be read from a text file which I could update as and when required.
Is this feasible? If yes, what are the pros and cons. If not, thank you for the information.
Cheers
You can't do that in iptables as you would like to.
What you have aren't 3 real different hosts, but 3 virtual hosts: the main difference, as you already know, is that they share the same IP address.
As they share the same IP, kernel's netfilter just can't distinguish different requests from its layer: it's your web server application itself that "routes" the different requests to its proper website by looking at the "Host:" header inside the incoming HTTP packet and by determining which virtualhost should reply to it.
A good compromise (denying instead of dropping) for what you want to do would be to setup a configuration in your web server to make it catch and deny any connection that doesn't belong to your virtual hosts. Also there's no need to make a different list in this way, as your web server could dinamically determine if the requested host exists or not.
Here's an example, assuming you're running Apache, adding the catchall sentence to the top will make your server respond with a 403 message to any connection that won't be overridden by your examples.com websites:
<VirtualHost *:80>
ServerName catchall
<Location />
Order allow,deny
Deny from all
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName example1.com
DocumentRoot /var/www/example1
<Directory /var/www/example1>
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
...
VirtualHost for example2.com (allowing all as above)
VirtualHost for example3.com (allowing all as above)
That's not the same as dropping right from the kernel of course, but it stops any further interation with your server aswell.

Url rewriting not working in WAMP Subdomain

I created a Subdomain under my WAMP server for mobile site and it uses IP address as the domain name which is 192.168.106.1
But the issue is that when I try to rewrite a url in my .htaccess file, I doesn't work. And I use a duplicated .htaccess file which works for the localhost
Below is my server configuration for the domain name in my httpd.conf file
<VirtualHost 192.168.106.1>
#LoadModule rewrite_module modules/mod_rewrite.so
# The name to respond to
ServerName m.localhost
# Folder where the files live
DocumentRoot "C:/wamp/www/mobile/"
# A few helpful settings...
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>
I also removed the comment tag on the second line but it still not working.
Please anyone with a solution?
Here is a solution
First make sure you go to your C:/wamp/bin/apache/YOUR APACHE VERSION/conf and open up your httpd.conf file and uncomment this line
#Include conf/extra/httpd-vhosts.conf
So it will look like this
Include conf/extra/httpd-vhosts.conf
Then also open up your host file located in C:/windows/System32/drivers/etc and add this (your ip address to the configuration)
#add the sub-domain name, in this case I use mobile, it can be anything
192.168.106.1 mobile.localhost
192.168.106.1 192.168.106.1
Then finally and most importantly, open up your vhost file in C:/wamp/bin/apache/YOUR APACHE VERSION/conf/extra/httpd-vhosts.conf and add this to the file
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/mobile"
ServerName m.localhost
Options Indexes FollowSymLinks
<Directory "C:/wamp/www/mobile">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
#If you want to allow access from your internal network
# For specific ip addresses add one line per ip address
Allow from 192.168.106.1
# For every ip in the subnet, just use the first 3 numbers of the subnet
#Allow from 192.168.0
</Directory>
</VirtualHost>
Then restart your WAMP server and it works

virtualhost without real domain name

I've this configuration for my virtual host and runs with real domains. For testing purpose I need create same virtual host with non real domain (i.e. domain10). Considerated that the browser check the name of domain of virtual host, I think using something like 127.0.0.1. But I've no idea to realize this.
<VirtualHost *:80>
ServerAdmin info#domain10.org
ServerName domain10.org
ServerAlias domain10.org
DirectoryIndex index.html index.htm index.php
DocumentRoot /home/domain10.org/
<Directory /home/domain10.org/>
Options -Includes -Indexes -FollowSymLinks -ExecCGI +MultiViews
AllowOverride none
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You can use the /etc/hosts file for this purpose. There should already be a line in it beginning with 127.0.0.1. Just add domain10.org to the list of hosts that resolves to this address.
For example, if the existing line is:
127.0.0.1 localhost localhost.localdomain
Just extend it to:
127.0.0.1 localhost localhost.localdomain domain10.org
Then (on this machine only) domain10.org will resolve to 127.0.0.1. If you are testing on the same machine, you can enter http://domain10.org/ in your browser to reach your local web server.
If you need to reach this host over the Internet, then a different approach is needed. Look for a line for the external IP address of the server in its /etc/hosts file and modify it similar to the above instructions. If such a line does not exist, add one.
On the client machine, do the same (using /etc/hosts for a Linux box or %WINDIR%\system32\drivers\etc\hosts for a Windows box). You should then be able to reach the server from the client using this name.

how to create a subdomain in a dedicated apache2 server

I want to create a subdomain I followed this steps :
cd /etc/apache2/sites-available
nano test.mydomaine.com
<VirtualHost *:80>
ServerAdmin mymail#gmail.com
ServerName test.mydomaine.com
ServerAlias www.test.mydomaine.com
DocumentRoot /var/www/testfolder/
<Directory "/var/www/testfolder">
AuthType Basic
AuthName "test"
AuthUserFile /var/www/testfolder/passwords
Require valid-user test
</Directory>
</VirtualHost>
exit and save
a2ensite test.mydomaine.com
/etc/init.d/apache2 reload
but It's not working am I missing something ?
In order for this to work, you additionally have to configure DNS resolution for the new hostname test.mydomain.com. If you are just playing with this locally and do not want to create a "real" DNS entry, you have to edit the file /etc/hosts so that your computer can resolve the hostname to an IP address. If you are running the web server on the same machine as the browser, you will want to map test.mydomain.com to 127.0.0.1. If the browser is on a different machine on your local network, you'll need to determine the server's IP address and then on the browser machine, edit /etc/hosts to add the mapping.
On Windows, the file is called C:\windows\system32\drivers\etc\hosts
A sample entry would be (for the browser running on the same machine as the server):
127.0.0.1 test.mydomain.com
If the server is at, say 192.168.0.5, the entry would be
192.168.0.5 test.mydomain.com
EDIT: If the server has a real routable IP address, then if you want the test.mydomain.com address to resolve on the global Internet you will have to get your service provider to add it to DNS. For testing purposes, you can still use /etc/hosts as described above. Just substitute the server's real IP instead of 127.0.0.1. Do this on the system where you are running the browser.

Creating subdomains in Amazon EC2

How can I create subdomains on Amazon EC2?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
Thanks
Depends on your server software. But as you mention httpd.conf, chances are good that you run Apache on a Linux distribution. If that's the case then yes, adding a virtual host is enough. Here is one way of doing it:
Purchase a domain. If you have one, skip this, we'll take example.com for this example.
Find the external IP or DNS for your EC2 instance. You probably want to associate an Elastic IP to your instance, otherwise the IP of your instance will change on reboots.
Create a DNS record for your domain, for instance a CNAME record to point to your Elastic IP/DNS name:
subdomain.example.com => ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
Make sure your httpd.conf contains a line to allow virtual hosts:
NameVirtualHost *:80
Create a virtual host directive:
httpd.conf:
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAdmin webmaster#subdomain.example.com
DocumentRoot /var/www/example.com/subdomain
<Directory /var/www/example.com/subdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/subdomain.example.com.error.log
LogLevel warn
CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>
6. Restart Apache
/etc/init.d/apache2 restart

Resources