Accessing Apache Server from the internet - apache

I have installed Apache on Xubuntu and I am have a problem accessing it from the internet.
If I access it via localhost I can reach the home page plus pages in the subdirectory. How if I access it from the internet I can get the home page but nothing else. When I type in the subdirectory and page, no links at this point, It either never leaves the home page or gets rerouted back to it.
I have no .htaccess files in place, I have tried adding an alias and entries in the conf file and I have checked ownership and permissions. I have gone as far as wiping the machine and starting with the same results.
I feel like it is going to be a case of missing something simple but I cannot think of what. The log files have indicated that an IP tried to access the subdirectory but shows no error in doing so. When typed into the URL the /Directory/Index.html shows in the address bar but it displays the home page.
Can anyone point me in the right direction?
Thanks,

Most likely the issue is contained either in your apache.conf file or your firewall. I would have a good look at your apache.conf to see if there is anything restricting access to your sub-directories.

if you want to use default http port (80), so long story short www.abc.com without explicit port number, you must allow this on your server because 80 is privileged on most system, this could be a problem

Related

Virtual server on virtualmin keeps redirecting to wrong website

I have created a virtual server say aaa.com but when I access the site (via editing my hosts file on Windows 7, cos I have a live aaa.com running on the Internet), it brings me to my other virtual server's site I have, like bbb.com
Why is that? I don't have any redirection running. Not in my script files (like html or php) and no redirection set under "Server Configurations" -> "Website Redirects" and none at "Services" -> "Click Configure Website" -> "Aliases and Redirects." The only script files I have are fresh new WordPress installation files (under home/aaa/public_html).
How do I fix this?
Mullazman is right (thanks!). I have just had this problem after enabling the SSL on the domain A. Then, all the domains in the same installation were pointing to A.
I fixed it by editing the file located in /etc/apache2/sites-enabled/A.conf and changing the first line:
Wrong line -> <VirtualHost A.B.C.D:80>
Correct line -> <VirtualHost *:80>
Had the same issue. For anyone interested it's because I had at the header of my sites-enables/aaa.com.conf which was picking up all requests and send them to the first host.
Change it to and it started directing traffic to the correct virtual hosts.
It was triggered when I enabled SSL on aaa.com, it for some reason re-wrote the config file to use IP based filtering not domain name
Try to delete browser cache with CTRL+F5,
then try again. If that doesn't help, check virtualhost configuration files -maybe there lies the problem.
The solution I found
I had the same problem ...
And I ended up with a lot of doubts ...
And I searched for a SOLUTION for this case, I hope to help ...
1 - Should the BIND have an external or internal IP in the domain? I use only one IP for all servers, and in BIND all domains are with external IP. (The question is whether it should be external or internal IP).
R = Yes, you must configure the internal IP in Virtualmin, prefer to edit the file. Only in localhost you should have 127.0.0.1
2 - Would NGINX have any configuration? How to remove IP and just put (listen *: 80) instead of (listen 288.218.198.981:80)
R = This configuration was changed but then I had problems with DNS and I returned to use the INTERNAL IP (not the localhost) ... Normally this IP starts as: 10.1xx.xx.xx
But which configuration would work in general?
Restart these steps ...
If you still have an error ...
Back up ... And in Virtualmin settings ...
Edit Virtual Server >> Activate Features >>
Uncheck NGINX, BIND, NGINX SSL.
He will ask for confirmation and click to confirm.
After this process is completed, return to the same option and reschedule ...
This will make it delete the old ones and put a new one.
(This works great for those who changed hosting and has old settings).
If you are importing a backup. Do not select the DNS and NGINX option ...
One tip is to create Virtual Server {your domain / site} First of all ...
And only then only import directories and databases ...
So you will not have problems with DNS and wrong redirects ...
Update
This also occurs when the SSL certificate is not issued correctly.
Folder permissions are incorrect.
Chmod 0755 folders
0644 Files
SOLUTION!!!
Cheap workaround let us say our domain is domain.xyz
Under the BindDNS Master Zone for domain.xyz create a cname record I believe it is listed in webmin as Name Alias and name it 000.domain.xyz
Under apache create a virtual server with the name 000.domain.xyz and make sure it has the same directory as domain.xyz
After this is done you are golden all your websites will come up as they should!
Is it proper well maybe not.
Does it work well like a charm of course otherwise I wouldn't be sharing for some reason the way the severs are listed it defaults to the first on the list well that'll fix that there should be a method of pinning the servers or doing something to prevent such a thing from happening what a pain in the rear I spent a full day dumbfounded thinking what in the world is going on I am losing my touch.
If this helps give a like if its wrong apologies all I know is that it works.
Read the thread.
Many folks claim this is an SSL thing.
Zero people have eluded to the true method of fixing it or the proper directions to do so or if they did I'm too blind to see it.
The guy below me commenting hrmmm... Yeah browser caches for my website didn't exist on my devices I tried them on to verify that was not the problem. But yes this is a typical problem with a lot of things indeed. It is the only reason I have several browsers on my PC actually for that reason. For a while there there were pages that chrome would function with that IE wouldn't or Firefox would best them both. Not to mention cache is always a pita its always usually one of my steps in troubleshooting any issues with web pages. I'll even try openDNS or other DNS servers.
But holy cats I can't believe how fast DNS just updates once you got things set it makes me wonder if there is a lot of fudge in propigation when you purchase hosting being "24 -48 hours" I think there is a lot of fudge in those numbers after my experiences trying to figure out what was causing the issue here. Some servers struggle yes but for the most part it was pretty instant for me.
In my case it happened after creating SSL certificate, I forgot to do:
Edit Virtual Server -> Enable Apache SSL Website

htaccess - simulating local page as web page

Is there a way to rewrite a URL in a local project to look like web page?
For example I have project with url
localhost/site
I'm tryin' to rewirite this to:
www.site.com
or
site.com
That project has subpages, and it would be good if it worked like
site.com/subpage.php
I'm trying for an hour but I'm really htaccess noob.
I work with VertrigoServ and mod_rewrite works fine with some examples which I tried in other projects.
The issue is not with rewrite. To make a local page appear to have a more conventional domain you need to tell your browser that the conventional domain is found on your local webserver.
The simplest way to do this is by editing the hosts file on your OS. On *nix based devices it's usually /etc/hosts, On windows it's usually C:\Windows\System32\drivers\etc\hosts. You will need elevated privileges to edit the file.
Add a line to the end of the file that maps the domain name to your local ip address like this:
127.0.0.1 www.site.com
Close an reopen your browser and visit www.site.com, you should see it is loading the page from your local webserver.
Chances are, you are still seeing the same page as if you view localhost site. To make it load your code you need to change the DocumentRoot in httpd.conf for your apache install to match the directory where your code is.
A preferable solution may be to use Name Based Virtual Hosting, this allows multiple web sites to share the same IP address. Searching 'apache VirtualHost examples' should give you plenty of resources for this. Make sure that NameVirtualHost *:80 is also enabled in order for this to work.

Using apache for dns blocking page and removing all jargon in URL

I have a little DNS Spoofing / Blocking system I setup for work. It simply uses a blacklist to spoof the dns records and simply points them to a BLOCK / DENY page.
If I go to the URL directly for instance http://www.redtube.com the system works as expected and displays my index.html and what it should
The problem arises if I go to http://www.redtube.com/video?/43 or anything other than the full domain I get a not found.
I need to to configure Apache so that it drops all the junk after the TLD and simply displays my page such as http://blocked.project.com
Another way to look at it would be to say redirect to index.html if the url entered is not known to the webserver.
Any help greatly appreciated.
Used an apache FallbackResource to achieve exactly what I was after. Had to make sure my image paths on the website were absolute but works a treat.
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource

"yourdomain/start is not the same thing as yourIP/start in Apache"

Let's say you're trying to get a CMS up and going.
And say you're supposed to find a Start Page at "www.yourdomain.com/start"
But you don't have a domain name yet. You only have an IP address.
So you look in "yourIPaddress/start"
(Apache is visibly running at yourIPaddress)
And you don't find anything there, just a 404 page.
And the person who installed it for you tells you: "In Apache, yourdomain/start is not the same thing as yourIP/start. Please read up on Apache server configuration to figure this out. And that's all the help I can give."
My question is: what concepts (re: Apache configuration) should I read up on so that I can find the start page?
Thoughts?
If the ip address is not exclusive for your website then it might be shared by other websites. In that case searching for details about virtual hosts you should be able to get more info.
what you can do to get things working is add to the hosts file on your machine
yourIPaddress www.yourdomain.com
and you should be able to access your website's start page from www.yourdomain.com/start.
Just remember to remove the entry from your hosts file after the www.yourdomain.com actually gets pointed to your yourIPaddres by your hosting provider.

Trouble setting up a subdomain on a VPS under Ubuntu and Apache

I'm a complete newbie when it comes to servers, so I need some help. Basically, I want to have a subdomain on my VPS. I'm not too concerned where the files reside, though of course I would like them separated if possible.
I found a guide to doing this that basically sums the procedure up in five steps:
Create directories to host the content of a new virtual site.
Make a copy of the /etc/apache2/sites-available/defaults file with a site appropriate name.
Change the two /var/www/ entries to the actual directory of the new site.
Add the ServerName line with the real domain name you will be hosting.
Use a2ensite to enable the new site, and finally reload Apache2 so it knows about the new site
I tried all of this, but I can't get it to work. I didn't get any errors at any point during this process, but when I enter the address with the subdomain into my browser, I get a "Server not found" error.
The company that hosts my VPS has an admin page where I can set up subdomains. Stupid question: do I have to do reconfigure the DNS records or something while doing this, or is it likely that the problem is caused by something else?
Additional note: I followed a guide on howtoforge.com when setting up the server, which in hindsight may not have been the brightest move on my part. It is possible that I made a mistake there that is somehow affecting me now?
Assuming you've setup the subdomain correctly in your VPS' admin page, the only thing left to check here is that you've actually created the subdomain in your DNS administration page (have you?). For example, I use afraid.org to manage my DNS records and to add a subdomain, it's essentially:
Type: A
Subdomain: sparky
Domain: example.com
Destination: 120.34.2.3 (this would be your VPS' IP address)
In general, you add a (sub)domain by:
sparky.example.com A 120.34.2.3
Please keep in mind that you want to add an A record (this is important!).