I set up a VPS for my project, but I can access it with myawesomeproject.com, but I got DNS error with www.myawesomeproject.com
My apache conf:
<VirtualHost *:80>
DocumentRoot /var/www/myawesomeproject/public
ServerName myawesomeproject.com
ServerAlias www.myawesomeproject.com
<Directory "/var/www/myawesomeproject/public/">
AllowOverride All
Options FollowSymLinks
</Directory>
ErrorLog /var/log/apache2/myawesomeproject-error_log
</VirtualHost>
I only have one DNS zone for it at the registrar:
Type - IP - TLS
A - 'MyVPS'sIP' - 3600
What's the problem?
The A Record is probably for your naked domain, so that's why the version without WWW is working.
You need to make an A record for the www subdomain pointing to the same IP as the naked domain, or create a CNAME record pointing to the naked domain.
Cheers
Related
we need our new dedicated IP address (and all future ones) to "point" to the same root directory of our VPS' "parent" domain (main domain with all business logic, where $_SERVER['host'] is detected to connect associated files etc. )
So, for example, domain.net (x.x.x.146) should show content of domain.com (x.x.x.170) etc
We have list of dedicated IPs, added to WHM. We have number of domain names, with those IPS as DNS A records. We have added those domains via cPanel to point to the same public_html..
But all the domains resolve to : cgi-sys/defaultwebpage.cgi with "SORRY! If you are the owner of this website, please contact your hosting provider:" error.
Any suggestions? This is supposed to be quite an easy task, but clearly - not so.
Thank you
Why do you need many IP address? one IP address should be enough for what you want to do.
Indeed HTTP/1.1 protocol is meant for this purpose: many different domains for one IP.
In your VPS you can use for example "Apache" as a Web server with this basic configuration:
ceate/edit on "/etc/apache2/sites-available/" example.com.conf :
<VirtualHost *:80>
DocumentRoot /home/user/pulic_html
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then create/edit example.org.conf:
<VirtualHost *:80>
ServerName example.org
Redirect permanent / http://example.com/
</VirtualHost>
and so on..
then to enable your configuration :
a2ensite example.com.conf example.org.conf
sudo service apache2 restart
If you still want to use many IPs you can install apache in every machine hosting the IP, then redirect to your main site/domain(http://example.com), as shown above. Otherwise, if your hosting provider allow, you can redirect your children domain to your parent domain from your provider website with GUI.
here is the solution. It is not ideal bot it looks like there's not much we can do, having cPanel/WHM installed.
<VirtualHost x.x.x.x:443>
ServerName domain.net
ServerAlias www.domain.net
DocumentRoot /home/user/public_html
#todo common contact mail
ServerAdmin support#domain.net
UseCanonicalName Off
<IfModule mod_suphp.c>
suPHP_UserGroup user user
</IfModule>
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain.net/chain.pem
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</IfModule>
<IfModule headers_module>
RequestHeader set X-HTTPS 1
</IfModule>
</VirtualHost>
redirect from 80 to 443 set separately:
RewriteEngine On
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
I want to add a subdomain api.example.com on Apache2.
Here is my configuration file for the domain.
<VirtualHost *:80>
ServerName api.winity.pw
ServerAdmin webmaster#winity.pw
DocumentRoot /var/www/api
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I tried to access it without working, here is my DNS configuration on CloudFlare
When I try to access it, I find myself in the /var/www/public directory and not /var/www/api.
First when asking here.
Google the question
Search on StackOverflow
Make a relevant title for you Create subdomain in Apache2
Specify your operating system not your type of server**
Use 443 port over SSL by changing <VirtualHost *:80> to <VirtualHost *:443>.
If you receive an HTTP 525 - SSL Handshake failed error from CloudFlare, use Flexible SSL option.
This append when you use Full SSL and you don't have a valid SSL certificat on your server.
For fix this issue, change the SSL option to Flexible.
I created CNAME record for new domain: www CNAME #, now, if I have many domains, shoud I always create a link 'www.example.com' to 'example.com' folder? My apache VHOST config is:
UseCanonicalName Off
VirtualDocumentRoot /home/colix/www/hosts/%0
VirtualScriptAlias /home/colix/www/hosts/%0/cgi-bin
for this case I always use ServerAlias directive in the config (see Apache Doc).
ServerName domain.tld
ServerAlias www.domain.tld
ServerAlias mx.domain.tld
Greetings,
M.
I'm trying to set up a subdomain for on a client's web server. It's a CentOS server running Apache. So say the website is "example.com". I'm trying to create "bugs.example.com".
So far, I've added to the vhost.conf file the subdomain info:
<VirtualHost *:80>
ServerName bugs.example.com
ServerAlias bugs.example.com
DocumentRoot /var/www/www.bugs.example.com
<Directory "/var/www/www.bugs.example.com">
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I've added the server's IP address and the subdomain to /etc/hosts:
111.222.333.444 bugs.example.com
I've created the directory for the website files, and an index page at:
/var/www/www.bugs.example.com/index.html
Sadly, I still get a "Server not found" error when I go to bug.example.com. What am I missing here? The example.com domain name is registered through GoDaddy.com. Is there something that needs to be done there?
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