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

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?

Related

Remote access of network computer

I am not sure how or if this can be done. I have a home network and would like to see a computer,not the server, via a remote location. I have Apache on my server. Example: the network computers I would like to see ip 152.254.1.33. Is there a way to add this ip to Apache root directory? I have tried to add a shortcut with in the root directory and it only works on the home network, will not via remote connection.
I need some clarification here on what you are trying to acomplish, are you trying to access the Apache website outside of the local network?
If that is the case, Apache is automatically set to listen on all network interfaces, you can check this in your virtual host configuration in the sites-enabled directory of your apache installation.
You should see something like in the 000-default.conf
You can test if apache is serving pages up correctly using the command
curl 127.0.0.1
You should see the HTML of the page being served.
If this is the case, then it's likely the firewall on your machine/router or your ISP is blocking the required ports. You can allow Apache through the firewall on Ubuntu using sudo ufw allow Apache Full
If you give me some more info in comments we can probably work this out.

apache not serving index.html unless specified

Im new to setting up apache - the site works fine on localhost but when I access it from the LAN it does now display the index.html file - instead the browser says:
This site can’t be reached
localhost refused to connect.
Ive tried editing the apache2.conf file but nothing seems to work
I think you made another mistake. When you are on a different Computer on you network, the Apache server is not available on http://localhost/ but on the domain name or IP of the Apache Server.
The browser tries to open a connection to your client computer. But its not on localhost.

Setting up Programm-o locally

After reading the installation guide for program-o http://blog.program-o.com/documentation-v2/installation/ I was wondering how I would go about doing step 2 locally and installing it without hosting an online server?
Just put your code in htdocs directory (inside xampp instalation directory).
Then You will be able to execute your code by typing 'localhost' in your browser.
Or if you want to use other domain instead of localhost, You have to edit your hosts file.
In Windows7 hosts file is located in:
%systemroot%\system32\drivers\etc
My hosts file for example:
127.0.0.1 domain.com
I can access my code by typing for example 'domain.com' instead of 'localhost'

Home apache web server - final hurdle

Ok, so bit of noob question - having one of those days.
I have set up a home apache web server on Ubuntu. I have configured vhosts as I want to host multiple websites. These work fine in the local browser, e.g.
http://site1
http://site2
both display their various contents.
For the server side of things, I've configured port forwarding on my router to send all port 80 requests to the server IP.
When I go to an external browser and type in my servers external IP address I get the standard apache "It works!" message. When I type in ipaddress/site1 I get 404. The site1 is not in the standard apache default directory, I have it in home/username/Sites/site1 folder and httpd.conf file knows this.
How is it I can access these site1 and site2 sites externally?
Cheers
Just as you would do in your local browser. So typing in http://site1 would lead you to the first site. This is based on an assumption though, which is that you put the http://site1 address in your /etc/hosts file. When your computer looks up an URL, it first checks the hosts file (and your case will find the correct IP address there) and next will ask a global mechanism for the address.
The reason why it doesnt find anything at "ipaddress/site1" is because of the vhosts configuration. This teel Apache serve the content of a folder somewhere on your server as a separate hostname, e.g. http://site1. If you're requesting "ipadress/site1", you're actually telling Apache to look in the folder "site1" in its first root it encounters in your Vhost configuration.

symlink or alias? Not sure what its called

I want to redirect request on my local webserver much like "http://localhost/" redirects to my ServerRoot. I have seen it done with "http://www/" and also with "http://helpdesk/" How would I go about adding my own?
Are you saying you want to redirect something like http://custom to your web server? If so you can do this by creating an entry in your hosts file, or configuring your local DNS server to return local addresses for those hostnames.
Add the following to your hosts file (On *nix /etc/hosts and C:\Windows\System32\drivers\etc\hosts on Windows)
127.0.0.1 custom www.custom
Then you can optionally configure a virtual host on your Apache server to handle requests for those hosts. If you don't create a virtual host, it will just serve up the same content as localhost. You can also have your local webserver host the site and add that entry to your local PC's hosts file and be able to browse it from that hostname as well.
If that isn't what you wanted, can you please clarify your question.