I have a server at work that is running windows server 2008. I have installed wamp on it and use it to host all my sites. For multiple sites, I include the following into the httpd.conf file:
<VirtualHost *:80>
ServerName www.NewURL.com
ServerAlias NewURL.com *.NewUrl.com
DocumentRoot "X:/www/NewURL/"
</VirtualHost>
After saving the httpd.conf file, I open up my DNS Manager, add the domain, and add 2 a records. The "Name" of the first is set to * (Making the FQDN = *.NewURL.com). I change the IP address to my servers local address (Let's say, 192.158.5.5).
This process has worked great for about 40-50 URLs, even allowing me to customerName.OldURL.com and still correctly retrieving the index.php file.
I have a new site I added to my httpd.conf file as well as my DNS manager. The website is available 100% while within my work ip address range, but when I test the site at home, only the main domain (www.NewURL.com) is reachable, not clientName.NewURL.com. clientName.NewURL.com times out and is unreachable according to www.isup.me. However, NewURL.com works just fine.
I've set up NewURL.com exactly as I have all the other URLs I'm running of this server. I've event gone through and started again from scratch... with the same result.
Anybody know of anything else I can check other than the virtual host settings and the DNS manager?
Related
I have a development server running Centos 7 I've setup in my living room. As of now I'm not using a domain, my ISP blocks port 80 so I've got Apache listening on port 8080.
I have a few different sites on here I've been playing with. One of them is a redmine installation, another is wordpress, and the other has dolphin on it. I can get any one of these 3 to run normally off the root ip xxx.xxx.xxx.xxx:8080 but when I try to setup an alias it points to the server's local ip. This works great from home, but I can't access them anywhere else.
I've setup a virtual host configuration in apache like this:
<VirtualHost *:8080>
DocumentRoot /var/www/html/wordpress
Alias /wordpress /var/www/html/wordpress
</VirtualHost>
When I open xxx.xxx.xxx.xxx:8080/wordpress it tries to redirect to the local ip 192.168.1.xxx:8080/wordpress I feel like I'm on the right track but I'm not sure where to go from here. Thank you.
I stumbled upon the solution today after running into something similar with a site I migrated for a client today. I was sure it had to be an apache issue.
The WP installation (and others) were pointing to my private IP as I'm not using domains for any of them. This is why I kept having the site redirect.
192.168.* are private network addresses. And by definition "IP packets addressed from them cannot be transmitted through the public Internet".
You have to get yourself a public IP or use a service like https://ngrok.com/.
Alias directive itself shouldn't cause redirect. There is something else (probably some Wordpress setting or .htaccess redirect) that is causing that when the page is opened (or not found)
I'm having trouble figuring out how virtual hosting works. For example lets say in my 'hosts' file I have:
127.0.0.1 localhost
127.0.0.1 mysite1.com mysite1.com mysite3.com
Does this mean that whenever I type in localhost, mysite1.com, mysite2.com, or mysite3.com into my browser URL, the page loaded will be the same for all of them?
The /etc/hosts file only has limited connection to virtual hosting of Apache. The only thing you do with it is give your host (or rather the loop back interace lo) several names. If you haven't set up anything about virtual hosting yet (which I assume) typing
http://localhost/
http://mysite1.com/
http://mysite2.com/
http://mysite3.com/
as URL in your browser will all render the same welcome page (provided you have at least set up your Apache) because in all cases the browser will try to access the web server at 127.0.0.1 which your Apache usually listens to.
To create a true virtual hosting you now need to activate this feature in the configuration file of Apache using the tags
<VirtualHost mysite1.com:80>
...
</VirtualHost>
<VirtualHost mysite2.com:80>
...
</VirtualHost>
<VirtualHost mysite3.com:80>
...
</VirtualHost>
The simplest version of a virtual hosting would be that you define a seperate document root for each host and share all other configuration items. The details of this (represented by the ...), of course, would definitely be out of scope of this answer. A good start for reading would be http://httpd.apache.org/docs/2.2/vhosts/examples.html.
I have a WAMP home web server up and running on a static IP and registered a domain with Namecheap, but I'm a bit shaky with DNS. At first I used URL Redirect and pointed it to my IP. This meant that when you typed in the domain (like example.com) it just redirected you right to my IP, replacing the domain name with it in the address bar. Now I'm trying to get the domain to show instead of the IP in the address bar, which I'm struggling to understand exactly how to do.
The latest thing I've tried which many people say to do is instead of using URL Redirect to use the A (Address) record type and point it to my IP, which I thought would finally fix my problems. Of course after 15 min or so when it all got updated I'm getting a 400 Bad Request with nginx under it in Firefox, and a blank page in Chrome. Now I'm getting blank pages in both. Did I do something wrong here? Do I need to edit something on the web server such as httpd.conf? Am I going at this completely wrong?
Yes you should do away with the redirect and instead create an "A record". The sub-domain entry would typically be, but is not restricted to "www". The record type "A" and destination/target would be your external IP address. Once you update this record it may take several hours before you notice it taking effecting, upon where on people typing your URL would be directed to your web server.
You will need to forward port 80 on your router to the server hosting WAMP.
Finally the WAMP server should be provided with your domain name so it knows which site to load. If use the VirtualHost file this will allow you to host multiple domains on your web server. To do this...
Uncomment the following line so it appears like below in your Apache httpd.conf, to allow Apache to use virutal hosts
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then locate the httpd-vhosts.conf file, should be found in your WAMP installation location, such as C:\wamp\bin\apache\apache*version_number*\conf\extra\
Add an entry for your site, altering the details to your own domain name and website location.
<VirtualHost *:80>
ServerName www.stackoverflow.com
ServerAlias stackoverflow.com
DocumentRoot "C:/websites/stackoverflow/"
ErrorLog "C:/websites/stackoverflow/logs/error.log"
CustomLog "C:/websites/stackoverflow/logs/access.log" common
</VirtualHost>
Now restart your WAMP server and give it a whirl.
Tip: If your server won't start after these changes, check that you have created the folder structure for the log files!
Solution described here could resolve this issue.
Most of the free dynamic dns providers, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org.
Now, go and configure your free domain names in the dashboard of free provider in the following way (assume your IP is 188.165.15.29 and your server's listening to port 8085).
redirect mysite1.somefree.org to mysite2.somefree.org:8085
redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29
This also works when you are using Apache httpd server alone, not being part of WAMP. You do not need to tweak virtual host or any part of your server. You only configure inbound direction.
Use Forward with masking where you registered your domain. mine is GoDaddy.
in the forward settings, you will see this at bottom of the page. click Forward with masking and add the title you want them to see in the address bar of the browser when they go to your site. instead of showing your IP address
I'm wondering if anyone can help me define a new local VirtualHost using Apache.
The goal is to have a site that is viewable only from the local network (hidden behind a firewall). Right now I have Webmin installed and it runs on transaction:10000. I am trying to get the other site running on transaction:7000.
The following does not work:
DocumentRoot /var/path
Is there a better way to do this? I'm new to Apache and trying to figure this out.
Summary: Need local /var/path directory to run on a port other than 80 for local access only.
I'm assuming that you don't know to Apache Virtual Host Code. I will show you how to use it. If this didn't help you please don't hesitate to reply to me.
You must place code in your HTTPD.CONF which can be found in the conf folder. If your file is called wwwroot instead just change the name in the code below BUT DO NOT CHANGE THE NAME OF THE FOLDER!!!
NameVirtualHost 111.22.33.44
<VirtualHost *:7000>
ServerName www.domain.tld
ServerPath /domain
DocumentRoot /htdocs/domain
</VirtualHost>
What does this mean? It means that a request for any URI beginning with "/domain" will be served from the virtual host www.domain.tld. This means that the pages can be accessed as domain.tld/domain/ for all clients, although clients sending a Host: header can also access it as domain.tld/.
In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/. Then, in the virtual host's pages, be sure to use either purely relative links (e.g., "file.html" or "../icons/image.gif") or links containing the prefacing /domain/ (e.g., "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html").
So all domains will be pointed to your IP address and based on the domain name if it is "www.domain.tld" it will take you to the folder "/htdocs/domain" or "/wwwroot/domain"
EDIT:
<Directory "/var/path/">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
This lets access to the "/var/path/" folder from only localhost which is where Apache is configured which is on your computer!
Good Luck!!!
I'm developing a few sites with Wordpress on a local server. I have my MAMP (2.0.1) running with the default port numbers for Apache and MySQL on Lion (10.7.2). It's been working quite well until I recently encountered a perplexing problem.
One site in particular has undergone a few internal domain/vhost changes (this is how I came to the conclusion of using the default port numbers re:my own Wordpress development) which are referenced in my /etc/hosts file and also in my MAMP apache httpd.conf VirtualHosts section. Now when I visit this particular development domain defined in the hosts and httpd.conf vhost, it gives me a browser error stating that it couldn't establish a connection to dev.example.com:8888 (the Wordpress index.php and htaccess files are in the folder index). I'm a bit annoyed and confused as I've changed the MAMP ports to the default, yet this references the 8888 default MAMP apache port only on the domain index and doesn't want to sway its course even if I visit dev.example.com:80. I can access files and folders within the domain by specifically typing them in, but visiting the domain index as it is gives me this error with the default port number. I have no idea why that is and haven't been able to find a solution via the internet.
Some search results have mentioned incorrect line formats in the hosts and httpd.conf files, but mine are all Unix LF based so that solution hasn't made a difference. I've removed Wordpress from the domain's folder structure and tried again but it still gives me the same error. On another domain I'm using with Wordpress it works fine; the folders are set up exactly the same way, as are the entries in the hosts and the httpd.conf files. I get no apache errors when I visit the particular erroring domain as well. I'm just a bit stumped on the whole thing.
Hosts entry:
127.0.0.1 dev.example.com
Vhost entry:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName dev.example.com
DocumentRoot "/Sites/example.com"
</VirtualHost>
Wordpress config:
sql.wp_options.siteurl = http://dev.example.com/wp
sql.wp_options.home = http://dev.example.com/