Subdomain on WAMP Server Not Working - apache

I'm having an important issue with my WAMP Server configuration. I've tried many configurations listed on many websites to no avail. I'm trying to make the directory /forums be accessible via https://forums.centmc.tk. However, upon travelling to https://forums.centmc.tk, it almost immediately says "forums.centmc.tk's server IP address could not be found." https://centmc.tk works fine, and so does the 301 redirect from https://centmc.tk/forums to https://forums.centmc.tk. I just can't figure out why the subdomain won't work.
I know it's an issue with my httpd-vhosts.conf file, so here's that:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "c:/wamp64/www"
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot c:/wamp64/www
ServerName centmc.tk
SSLEngine on
SSLCertificateFile c:/wamp64/bin/apache/apache2.4.27/conf/centmc.tk.crt
SSLCertificateKeyFile c:/wamp64/bin/apache/apache2.4.27/conf/centmc.tk.key
Redirect 301 /forums https://forums.centmc.tk
Redirect 301 /forum https://forums.centmc.tk
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName centmc.tk
ServerAlias forums.centmc.tk
VirtualDocumentRoot "c:/wamp/www/forums"
ErrorLog "c:/wamp64/bin/apache/apache2.4.27/logs/errors.log"
<Directory "c:/wamp/www/forums">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Thanks for any help in advance! Sorry for the rather large text brick at the top.

Lucas.
Sounds like a DNS problem. If you are running a DNS server on your network, you will need to add an "A" record for the "forums" subdomain. Something like this:
; example.com [448369]
$TTL 86400
# IN SOA ns1.linode.com. admin.example.com. 2013062147 14400 14400 1209600 86400
# MX 10 mail.example.com.
# A ###.###.###.###
mail A ###.###.###.###
www A <put your server IP here>
forums A <put your forums server IP here>
If you're using public DNS servers (like 8.8.8.8, 4.4.4.4, or just your default ISP's DNS servers... you'll need to add a CNAME record to wherever your domain name is registered. (GoDaddy for example). Here's a link to how to do it on GoDaddy: https://www.godaddy.com/help/add-a-subdomain-that-points-to-an-ip-address-4080
I hope that helps.

Related

Apache virtual host subdomains not working

I am using httpd-vhosts.conf,apache version 2.4.51 and Windows Server.
The subdomain is not working.
httpd-vhosts.conf:
NameVirtualHost *:80
#
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "e:/wamp64/www/mydomain.com"
<Directory "e:/wamp64/www/mydomain.com/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ServerAlias subdomain.mydomain.com
DocumentRoot "e:/wamp64/www/mydomain.com/subdomain"
<Directory "e:/wamp64/www/mydomain.com/subdomain/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Both mydomain.com and www.mydomain.com works great!
But if i try using: http://subdomain.mydomain.com i always got the error:
Hmm. We’re having trouble finding that site.
We can’t connect to the server at subdomain.mydomain.com
If that address is correct, here are three other things you can try:
Try again later.
Check your network connection.
If you are connected but behind a firewall, check that Firefox has permission to access the Web.
hosts file is correct too:
127.0.0.1 mydomain.com
::1 mydomain.com
127.0.0.1 subdomain.mydomain.com
::1 subdomain.mydomain.com
P.S. I can access it directly from the host machine, but i can't on another device.
Why only the subdomain is not working, please?
What am i missing?
Thank you!!!
It seems to be more a DNS problem than a config problem on your serveur. Did you set any DNS for your subdomain ? Maybe you could find some help here :
https://www.godaddy.com/help/create-a-subdomain-4080

WAMP Server will not allow access to website using "www"

I cannot access my website using "www" before domain name but I can if I don't use the "www". I would like to have both accessible.
I am very familiar using Apache2 Server on Linux but it's not often I have to use it alongside WAMP. I have done plenty of messing around in the config files and have tried a few different methods but nothing seems to be working.
Here is the httpd-vhosts.conf file:
# Virtual Hosts
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName wherehousemke.com
DocumentRoot "c:/wamp64/www/wherehousemke"
<Directory "c:/wamp64/www/wherehousemke/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
Require all granted
</Directory>
</VirtualHost>
The website that I am trying to get this to work for is http://wherehousemke.com. That URL is working but if you add "www" in there It will NOT work.
you need to add a DNS record that redirects from your TLD to the www subdomain https://www.digitalocean.com/community/questions/using-cname-for-www-redirection

How apache2 can deny connections to a domain which is not hosted

I am hosting website iplocation.io on a cloud server. I found a domain https://chrissloey.com/index.php which opens my website within it.
Now from what I understand, chrissloey.com has pointed it A record to my server ip and my apache2 server is not denying connection to it and allow's to open iplocation.io website content like its own.
I want apache2 to deny connections to any other domain and only allow my own domain to server content.
Attached is apache conf file for iplocation.io
<VirtualHost *:80>
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
ServerName iplocation.io
ServerAlias www.iplocation.io
ErrorLog ${APACHE_LOG_DIR}/apache-error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName iplocation.io
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
SSLEngine on
SSLCertificateFile /path-to-csr
SSLCertificateKeyFile /path-to-key
SSLCertificateChainFile /path-to-ca
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
</IfModule
Looking at the two comments I think the combination makes most sense:
Configure httpd to respond with redirect (301) to all incoming requests. This could be done on the 'root' host.
Configure a virtualhost listening to your domain only, and this one would serve your real content only.
This will work unless the other site requests your content and then integrates it into their responses. But as you said someone else simply put up a DNS A record.

Different site at HTTP vs HTTPS

I am taking over a multi-site Apache server, with two websites (A and B). Going to website A's url via http works fine. Going to the same url, but using https, shows website B. Why is this, and how do I make https://urlA.com go to website A?
I solved the problem.
The servers were set up with VirtualHosts, but there was no VirtualHost for port 443. So it looked something like this:
<VirtualHost 99.9.9.999:80>
DocumentRoot /var/www/example
ServerName example.com
<Directory "/var/www/example">
Options Indexes
AllowOverride None
DirectoryIndex index.php index.html
Order allow,deny
Allow from all
</Directory>
Adding a VirtualHost listening on port 443, with the SSLCertFiles specified fixed the problem.
<VirtualHost 99.9.9.999:443>
DocumentRoot /var/www/example
ServerName example.com
<Directory "/var/www/example">
Options Indexes
AllowOverride None
DirectoryIndex index.php index.html
Order allow,deny
Allow from all
</Directory>
SSLCertificateFile /etc/httpd/conf/example.crt
SSLCertificateKeyFile /etc/httpd/conf/_.example.key
SSLCertificateChainFile /etc/httpd/conf/gd_example.crt
SSLEngine on
</VirtualHost>

apache virtual host redirect traffic works in LAN but not WAN

I have a domain hosted by yahoo.
But i am using my own in house server to actually host my Domain and cloud sub domain.
so in the Yahoo, i forward all www.mydomain.com to my static ip
<meta http-equiv="refresh" content="0; url=http://111.111.111.111">
and all my sub-domain traffic to my static ip:
<meta http-equiv="refresh" content="0;URL=http://111.111.111.111/cloud" />
My in-house server is Apache 2.4.7 on Ubuntu 14.04LTS. I have created a virtual host site and enabled it and it works very well as long as i am in the LAN. When i am on the WAN, however, the web browser times out saying that the server stopped working.
I think i know where the problem is, but i am not sure how to solve it, namely in the redirect to the htpps - i am using a LAN IP. Using my static IP or my domain name did not help me solve this. here is my enabled site for my virtual host:
<VirtualHost *:80>
ServerAdmin admin#myexample.com
ServerName www.myexample.com
ServerAlias myexample.com
DocumentRoot /var/www/html/example-test/
Alias / /var/www/html/example-test/
### Redirect /cloud https://www.myexample.com/cloud
Redirect /cloud https://192.168.1.122/cloud
### Redirect /cloud https://111.111.111.111/cloud
<Directory /var/www/html/example-test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache_http_myexample.com.error.log
</VirtualHost>
### <VirtualHost www.myexample.com:443>
<VirtualHost 192.168.1.122:443>
### <VirtualHost 111.111.111.111:443>
ServerAdmin admin#myexample.com
ServerName www.myexample.com
ServerAlias myexample.com
Alias /cloud /var/www/owncloud
DocumentRoot /var/www/owncloud/
####Configuration for SSL #####
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/examplecloud.pem
SSLCertificateKeyFile /etc/apache2/ssl/examplecloud.key
#### End of SSL Configuration ####
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache_https_cloud.myexample.com.error.log
</VirtualHost>
~
Any help/insight would be much appreciated...
thanks,
Try Redirect permanent /cloud https://192.168.1.122/cloud
If that didn't work, try a more generic solution by replacing Redirect with:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}