Apache Configuration for Local Server - apache

I have a development server running Centos 7 I've setup in my living room. As of now I'm not using a domain, my ISP blocks port 80 so I've got Apache listening on port 8080.
I have a few different sites on here I've been playing with. One of them is a redmine installation, another is wordpress, and the other has dolphin on it. I can get any one of these 3 to run normally off the root ip xxx.xxx.xxx.xxx:8080 but when I try to setup an alias it points to the server's local ip. This works great from home, but I can't access them anywhere else.
I've setup a virtual host configuration in apache like this:
<VirtualHost *:8080>
DocumentRoot /var/www/html/wordpress
Alias /wordpress /var/www/html/wordpress
</VirtualHost>
When I open xxx.xxx.xxx.xxx:8080/wordpress it tries to redirect to the local ip 192.168.1.xxx:8080/wordpress I feel like I'm on the right track but I'm not sure where to go from here. Thank you.

I stumbled upon the solution today after running into something similar with a site I migrated for a client today. I was sure it had to be an apache issue.
The WP installation (and others) were pointing to my private IP as I'm not using domains for any of them. This is why I kept having the site redirect.

192.168.* are private network addresses. And by definition "IP packets addressed from them cannot be transmitted through the public Internet".
You have to get yourself a public IP or use a service like https://ngrok.com/.

Alias directive itself shouldn't cause redirect. There is something else (probably some Wordpress setting or .htaccess redirect) that is causing that when the page is opened (or not found)

Related

apache - how to redirect to another server

I have the following problem:
I have my HomeServer on IP 192.168.0.1, it's an exposed host, getting every access from outside.
On this Server I have running some lxc containerts, two of them have apache2, etc on it.
Now I want to access every server via a special URL, for example:
cloud.example.com -> going to the "cloud" container on IP 192.168.0.101
torrent.example.com -> going to the "torrent" container on IP 192.168.0.103
everything else should go the HomeServer on 192.168.0.1
I thought of it like this: everything should go to 192.168.0.1, there I would have some VirtualHosts looking for the URL and forwarding the traffic to the needed server or showing the "default" page of the HomeServer (192.168.0.1)
The thing is, I've searched for quite a while but can't find the stuff I need.
Someone an idea?
Thanks in advance
Something like that maybe :
<VirtualHost *:80>
ServerName cloud.example.com:80
ProxyPass / http://192.168.0.101/
ProxyPassReverse / http://192.168.0.101/
</VirtualHost>
The "default page" being in the document root of the main configuration (not the virtual host).
You could also try using Caddy web server as a reverse proxy, it is the simplest to manage that I've come across and the config file is much simpler than Apache or NGINX.
I am now using HAProxy and it's working perfectly.
Send requests from outside to router -> router sends it to HAProxy container -> HAProxy sends it to the needed container

Hosting Multiple Sites On Same Apache Instance (ReviewBoard, MediaWiki)

We're trying to set up two sites on same Apache instance, although on different ports.
We have a ReviewBoard set up on an Apache in an AWS instance. It runs on 443, and is working fine.
Now, we're trying to set up MediaWiki on same server. I'm assuming safest and fastest way is to set it to listen on a different port. So, we've set up Apache to listen on 8443, and enabled MediaWiki like so
<IfModule mod_ssl.c>
<VirtualHost _default_:8443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/<domain_name>
This is working fine for accessing homepage of wiki.
following are the issues we're facing -
This setup requires adding port to the URL. Since https by default uses 443, we need to add :8443 at end of url to access Wiki Page. Ideally, we'd like to do away with the port.
MediaWiki Login doesn't work. After login, user is redirected to port 80. If this port is blocked, which is what we want, whole flow is dead in water.
We'd like to use same AWS instance, although we're open to setting up another instance of Apache (not sure if it is possible / best practice).
Any ideas?
For issue number 2, make sure that you've updated your $wgServer variable to include the not-standard port number like so $wgServer = "https://127.0.0.1:8443";
Thanks TyA.
Solved this.
Multiple domain with the same ip and port in apache
TyA's solution.
Separate AWS or Apache instance not required.

IP address is shown in address bar instead of domain

I have a WAMP home web server up and running on a static IP and registered a domain with Namecheap, but I'm a bit shaky with DNS. At first I used URL Redirect and pointed it to my IP. This meant that when you typed in the domain (like example.com) it just redirected you right to my IP, replacing the domain name with it in the address bar. Now I'm trying to get the domain to show instead of the IP in the address bar, which I'm struggling to understand exactly how to do.
The latest thing I've tried which many people say to do is instead of using URL Redirect to use the A (Address) record type and point it to my IP, which I thought would finally fix my problems. Of course after 15 min or so when it all got updated I'm getting a 400 Bad Request with nginx under it in Firefox, and a blank page in Chrome. Now I'm getting blank pages in both. Did I do something wrong here? Do I need to edit something on the web server such as httpd.conf? Am I going at this completely wrong?
Yes you should do away with the redirect and instead create an "A record". The sub-domain entry would typically be, but is not restricted to "www". The record type "A" and destination/target would be your external IP address. Once you update this record it may take several hours before you notice it taking effecting, upon where on people typing your URL would be directed to your web server.
You will need to forward port 80 on your router to the server hosting WAMP.
Finally the WAMP server should be provided with your domain name so it knows which site to load. If use the VirtualHost file this will allow you to host multiple domains on your web server. To do this...
Uncomment the following line so it appears like below in your Apache httpd.conf, to allow Apache to use virutal hosts
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then locate the httpd-vhosts.conf file, should be found in your WAMP installation location, such as C:\wamp\bin\apache\apache*version_number*\conf\extra\
Add an entry for your site, altering the details to your own domain name and website location.
<VirtualHost *:80>
ServerName www.stackoverflow.com
ServerAlias stackoverflow.com
DocumentRoot "C:/websites/stackoverflow/"
ErrorLog "C:/websites/stackoverflow/logs/error.log"
CustomLog "C:/websites/stackoverflow/logs/access.log" common
</VirtualHost>
Now restart your WAMP server and give it a whirl.
Tip: If your server won't start after these changes, check that you have created the folder structure for the log files!
Solution described here could resolve this issue.
Most of the free dynamic dns providers, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org.
Now, go and configure your free domain names in the dashboard of free provider in the following way (assume your IP is 188.165.15.29 and your server's listening to port 8085).
redirect mysite1.somefree.org to mysite2.somefree.org:8085
redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29
This also works when you are using Apache httpd server alone, not being part of WAMP. You do not need to tweak virtual host or any part of your server. You only configure inbound direction.
Use Forward with masking where you registered your domain. mine is GoDaddy.
in the forward settings, you will see this at bottom of the page. click Forward with masking and add the title you want them to see in the address bar of the browser when they go to your site. instead of showing your IP address

iis and apache combination on real server for 403

We have a win2003 server that run both IIS 7 and apache (using wamp server 2.2).
We put on both server a page named test.html that show us a message that say "You are on IIS page" and "You are on WAMP page" to show us if everything is working correctly.
Both running real great locally. IIS is listening on port 80 and apache on port 8082. The problems come remotly. Both services are running and wamp is fully online (green icon + "put online" option activate).
Locally, on the server, doing http://localhost/test.html and http://localhost:8082/test.html show the correct pages. If we replace localhost by real IP address (for example purpose, let say http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html), still work. (not actual address but address used for real is the same used by dns web service)
Remotly, from any other PC, doing http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html, the first give us the website normally, the second give us a HTTP 403 FORBIDEN (tried using both htaccess and windows permission, still have 403). The same way, using http://www.ourdomain.com/test.html and http://www.ourdomain.com:8082/test.html give us the exact same result (first ok, second 403)
Is it possible to make it work correctly?
Thanks in advance.
edit: Just to add to the solution :
the firewall was blocking me, add the wamp on this port allowed
in my configuration, i had in my directory statement Require local, which needed to be set to Require all granted
for the rest, the solution was pretty it.
Thanks again.
The fact that you can get to the sites locally tells me both servers are setup correctly and listening on respective ports.
Upon further questions, the OP indicated that the Servername Directive, is pointing to localhost and it should be changed as.
ServerName localhost:8082
To
ServerName example.com:8082 # or add "ServerAlias example.com:8082" to your existing.
Where as example.com is your site DNS. Then in your [System32\drivers\etc\hosts] point that DNS to the ip of your Remote host.
403 is happening because the request from the remote is not matched against any Servername or ServerAlias and it falls to the default handler which normally has stricket permissions. If you look closely in logs(/logs/apache/access.log), there should be something about "access denied by server configuration /somelocation like your default DocRoot"
If you make request for http://example.com and you have correct ip in your hostfile, you can trace what happens to that request in the remote host and where it ends up(firewalls, Apache etc). Apache is good at logging and you just need to find relevant log entries!

One virtual host not responding to subdomains while all others work

I have a server at work that is running windows server 2008. I have installed wamp on it and use it to host all my sites. For multiple sites, I include the following into the httpd.conf file:
<VirtualHost *:80>
ServerName www.NewURL.com
ServerAlias NewURL.com *.NewUrl.com
DocumentRoot "X:/www/NewURL/"
</VirtualHost>
After saving the httpd.conf file, I open up my DNS Manager, add the domain, and add 2 a records. The "Name" of the first is set to * (Making the FQDN = *.NewURL.com). I change the IP address to my servers local address (Let's say, 192.158.5.5).
This process has worked great for about 40-50 URLs, even allowing me to customerName.OldURL.com and still correctly retrieving the index.php file.
I have a new site I added to my httpd.conf file as well as my DNS manager. The website is available 100% while within my work ip address range, but when I test the site at home, only the main domain (www.NewURL.com) is reachable, not clientName.NewURL.com. clientName.NewURL.com times out and is unreachable according to www.isup.me. However, NewURL.com works just fine.
I've set up NewURL.com exactly as I have all the other URLs I'm running of this server. I've event gone through and started again from scratch... with the same result.
Anybody know of anything else I can check other than the virtual host settings and the DNS manager?