How do I configure apache for subdomains on pi in my own local network? - apache

I want to access multiple websites at home on my pi apache server, like this:
projectA.localhost
projectB.localhost
or :
projectA.192.168.0.24 - IP of my pi.
I have tried to add vhost, but nothing has changed.
I can redirect my /var/www/ to other places but i want have a structur like:
/var/www/websites/projectA
/var/www/websites/projectB

I do this by modifying the hosts file on machines on my LAN that will access the server. That way, there is no special magic that has to occur in Apache (meaning that the web site can be moved to a public host without re-configuration.)
For example, configure Apache as typical with virtual hosts projecta.com and projectb.com (or projecta.localhost and projectb.localhost, if you prefer). There is no special Apache configuration on the server.
On the systems that will access projecta and projectb, configure the hosts file to point to the server's IP address:
projecta.com 192.168.0.24
projectb.com 192.168.0.24
-or-
projecta.localhost 192.168.0.24
projectb.localhost 192.168.0.24
Apache will properly route requests to the appropriate site.

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.

Apache2 virtualhost configuration trouble

This is my situation:
I have Redmine and Gitlab in my server which does not have a domain associated, because I will use the server IP address.
I want to configure two virtualhosts in apache2 with SSL in order to serve the above web applications, so I can access them like this:
https://x.y.z/redmine
which is located in /var/www/
https://x.y.z/gitlab
located in /home/git/github/public
I have configured apache by enabling two files in site-enabled: github.vhost and gitlab.vhost. The problem is that I cannot set gitlab to be accessible with
https://x.y.z/github
but only in
https://x.y.z
probably beacuse I do not use a domain but only the IP address of the server, and I don't know exactly how to manage it.
I would need some suggestion on how to correctly set the two vhost files.
Any suggestion?

Access virtual host on apache without host redirection?

I have apache 2.4 installed on Ubuntu server 14.04 and have setup different virtual host like domain1.com,domain2.com,domain3.com. The web server is meant to be accessed only from local network. So I tried to edit /windows/syste32/drivers/hosts and added line like this
192.168.1.90 domain1.com
and can now access the domain1 from that machine by simply putting domain1.com in browser. However I wonder if I can access specific virtual host on apache without editing the hosts file, I mean entering something like this in browser
192.168.1.90/domain1.com
, but this doesn't work since apache tries to retrieve content from the default host. In other words: If I know the apache server ip and virtual host domain, can I access it via browser directly?

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.