Domain name not pointing on root directory - apache

I am using amazon linux ec2 instance i.e working fine with IP address.
My apache root directory is
/var/www/html
that is working fine when I am accessing my instance IP address.
Issue is when I am using my domain name. It's working only when I am adding "html" after domain name, like
domain/html
I implemented SSL certificate using let's encrypt library, may be that is reason of this issue
I tried to change my httpd.conf directory URL with www directory but that's not working.
Domain name continuously showing below error message but working when I am adding "html" at the end of domain name
Forbidden
You don't have permission to access this resource.

Looks like issue is with your vhost config, as you mentioned SSL certificates generated using Let's encrypt, check host file on below path and change document root directory with your original directory. Also check is there any other host file as well or not.
/etc/httpd/conf.d/vhost-le-ssl.conf

Related

Domain for main document root gets pointed to newly enabled subdomain document root

I have a Ubuntu 16.04 which apache2 server is running. I have a website hosted in my primary domain which the document root is /var/www/html.
I use Webmin to create a subdomain and I have given the document root as /var/www/mysite.
when I restart the server and visit the main domain, it shows the website that I hosted in the /var/www/mysite, which is the subdomain document root.
If I remove or rename the conf file under /etc/apache2/sites-available/{created-subdomain.conf} file, the main domain again shows the website hosted in the /var/www/html document root.
What are the possible causes for this. I want my main domain to show the website I hosted in /var/www/html and subdomain to show the website I placed in /var/www/mysite
Sounds like you're not setting up ServerName domain.com in your configs, so Apache simply chooses the first one (alphabetically by Config file name) to serve.

Point root domain to Heroku without IP and CNAME (Rails)

My domain provider uses only A records with IP addresses for root domains and Heroku doesn't accept that. I was told to use an .htaccess file to point mydomain.com to www.mydomain.com which is linked with a CNAME record and secured with SSL on Heroku.
I have no idea how this works and according to the apache doc, using an htaccess file reduces the HTTP server's speed. Instead I should write the configuration inside a <Directory> block in the main server configuration file.
Has anyone any recommendations? If I have to use the <Directory> block, where can I find the main server config file?
You could use a Heroku add-on like PointDNS, where you can point your root domain to Heroku via PointDNS Nameservers.
For steps, follow: https://www.mirrorcommunications.com/blog/how-to-correctly-point-your-domain-to-heroku, Option #1

How to create an Apache Virtual Hosts for a non-local website?

I installed Apache on my local machine. I created 2 Apache virtual hosts with conf files for www.mysite.local and www2.mysite.local. I followed this tutorial : https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Now I would like to create a conf file for www.google.com and display a message writing in the index.html file. I followed the same tutorial, I created a index.html file in /var/www/www.google.com/public_html/, I created a file www.google.com.conf in /etc/apache2/sites-available, I edit my local file adding www.google.com on my VPS IP address. But google didn't display the message I want and display an error : "Your connection is not private".
This process doesn't work because it's not a local site? Do you know if there is an other process to configure non local websites?
Thank you!
This is because your browser will have cached that www.google.com has HSTS, so it will only connect to that site with HTTPS. For what you're trying to do, which is to have a faked domain, why not use the explicitly non-real domain example.com?

DigitalOcean hosting with GoDaddy domain denying access to root directory

I own a domain on GoDaddy and am attempting to point it to my DigitalOcean-hosted website. Here are the steps I have taken so far:
I cloned the git repo containing all of my website files from local to my DigitalOcean server.
I added an # record on godaddy for my domain and pointed it to my DigitalOcean IP address.
IMPORTANT!! I modified /etc/apache2/sites-enabled/000-default.conf with my new VirtualHost pointing mydomain.com to index.html, NOT THE ROOT DIRECTORY.
I then proceeded to do 'service apache2 restart' while sshed to DigitalOcean on terminal.
I assumed this would work and then tested it out and went to mydomain.com. Not so much. This is the error I got:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at mydomain.com Port 80
This was obviously pretty surprising given that it was not redirecting to index.html, so I manually appended /index.html to mydomain.com only to find that it gave me an identical error only I could not access /index.html instead of /.
I have done this kind of things many times before, however I used subdomain records for godaddy on an existing domain instead of using a brand new domain with no subdomains. Where did I go wrong?
Thanks!
Brandon
UPDATE: I tried on a test subdomain with test.mydomain.com and got this new error:
Not Found
The requested URL / was not found on this server.
Apache/2.4.7 (Ubuntu) Server at test.mydomain.com Port 80
You noted you modified the virtual host to point to index.html but not the root directory. Apache would still use the root directory (DocumentRoot) to locate the index.html file. If it is looking in the wrong location it could explain the 403 error (looking in a place that the web server user [www-data] cannot read as an example).
Beyond that, a 403 like that could be permission related. You would want to ensure the DocumentRoot and index.html file have the ownership of www-data:www-data and they are all readable by the web server itself (755 for folders and 644 for files is the norm).

Mapping folder to different folder on the same Apache Server

I have My old domain on my server myexample.com with folder name "myexample" and a have different domain mymaindomain.com, What i am looking is whenever user opens mymaindomain.com/contest it opens the site that is in "myexample" folder and still keep the url in address bar mymaindomain.com/contest/whatever.xxx using htaccess or httpd on apache server.
Put
Alias /contest /public_html/myexample
in the virtual host definition for myexample.com. Note though, that this may cause links in your content to be wrong if they expect to be located at / instead of at /contest.