How can I change all my links on my Apache site to look for port 8080 instead of 80 after changing my site from 80? - apache

My local Apache environment, on XAMPP, was set up to listen on port 80. I now changed it to listen to port 8080. my site now works on port 8080. I have to go to mysite.local:8080 to make it work, which is fine. The only problem is when I click a link it goes to mysite.local/page instead of mysite.local:8080/page and the page does not work. Also, some of my pages that use a log in require me to NOT use 8080 in the url so I have to use mysite.local/admin instead of mysite.local:8080/admin so I am constantaly swithing between adding the port number in the url and taking it away for some other pages. Is there a way where I can make it where I don't have to specify port number on any of the pages. This happened after installing IIS by the way.
My vhost page now looks like the below:
<VirtualHost mysite.local:8080>
DocumentRoot "C:\repos\www.mysite.org\web"
ServerName mysite.local
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "C:\repos\www.mysite.org\web">
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>

The problem is, that after you changed Apache to listen on 8080 Apache does not even see traffic on :80 (and that's where default HTTP traffic goes).
As you said that you have IIS listening on :80, the only way to solve your problem is to make IIS act as a reverse proxy that would forward all the traffic that should be meant for Apache to Apache.

Related

Using IIS and Apache on same server

I have a server running both Apache and IIS. IIS is using port 80 and every domain name hosted on the server using iis works fine. Now i also have apache running and is listen on port 8080. Is is possible that i have a domain www.example.com and it uses Apache, but i do not have to type www.example.com:8080 to get the site , but i go on www.example.com to get the site. I can host php on iis and all that but i want to use Apache for that website. I am currently this on httpd.conf
<VirtualHost *>
DocumentRoot "${path}/data/localweb/example"
ServerName www.example.com
<Directory "${path}/data/localweb/example">
Options FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
#Deny from all
Require all granted
</Directory>
# Other directives here
</VirtualHost>
If you have the ability to use multiple IP address oh the web server you could bind the IIS site to one on port 80 and the Apache site to port 80 on the second. If it's a VM you can just add another virtual network interface, if it's a physical server you can add a new network card.
If you only have one IP address you could setup ARR+ URL rewrite to use the IIS server to act as a reverse proxy to the apache site.

Apache reverse proxy, one server, multiple domains

I am trying to manage 2 domains with one server (running proxmox with several CT), I am using reverse proxy but seems to be wrong.. here's my configuration:
Let's say we have the main server running proxmox where I managed IPTables to redirect port 80 to the port 80 of my first container (CT01) and port 8109 to port 80 of my second container (CT02).
While using the port in my browser, everything is working well, and I am able to reach each container.
I bought 2 domain names, one for my private server (CT01) and another one for a business server (CT02). I associated both of the domain to my server address, and while typing one or another of them I am redirected to CT01 (normal, browser is running the address to the default port).
So now I tried to use reverse proxy in order to redirect to the desired server (DomainA -> CT01, DomainB -> CT02), I created 2 files in /var/apache2/sites-available/ :
/var/apache2/sites-available/domainA.com:
<VirtualHost *:80>
ServerName domainA.com
DocumentRoot /var/www/
</VirtualHost>
/var/apache2/sites-available/domainB.com:
<VirtualHost *:80>
ServerName domainB.com
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://x.y.z.h:8109/
ProxyPassReverse / http://x.y.z.h:8109/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Then I runned a2ensite domainA.com and a2ensite domainB.com. I restarted my apache service.
But nothing have changed: both my domainA and domainB redirect me to the same container (CT01).
Any idea?
What i may suggest is doing a new CT just to host a proxy (nginx for example) that will route the requests to one or the other site depending of the Host: field value of the HTTP request. This may be a little bit overkill if it's just for two sites, but when you want to have more, it can be very useful. Plus the NGinx can be used to cache, etc.
Let me know if you are interested. I know a tutorial that you may follow, but it's in french : http://blog.ganbaranai.fr/2013/08/il-etait-une-fois-proxmox-derriere-une-ip-unique/
Hope it helps.
Regards,

Remove Port Number from URL Thin Server 1.5 with Rails 3

I have a small Rails app currently being served (dev and production) by Thin server on port 3000, on a Debian box that also has apache2 running, serving PHP applications.
I am not certain if this is even possible given the current setup but is there a way to remove the port number from the rails app url but still have Thin listening from the same port so not to bump into apache?
Current
https://my-rails-site:3000/
Proposed
https://my-rails-site/
Or should I just use something like Passenger?
OR
mod_proxy?
You want to remove the port number from the URL and have your app listening on a non-standard port at the same time? Then you must have Apache/Nginx must listen on the standard port and proxy requests to your app's non-standard port. You need to either setup Apache with mod_proxy or Nginx with proxy_module.
If you just want your app to be accessible over a standard port then you can just use Phusion Passenger, that makes things very easy.
If you are using passenger here is what I had to use to get it working on www.mysite.com without using www.mysite.com:80 on a centos server:
In etc/httpd/conf the key was to uncomment the NameVirtualHost *:80 and change the * to my server's IP address. Make sure Listen 80 is uncommented. Also add your ip to the VirtualHost tag. It must be running on port 80, not 8080 or something of your choosing.
NameVirtualHost xx.xx.xx.xx:80
Listen 80
<VirtualHost xx.xx.xx.xx:80>
ServerName www.mysite.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/vhosts/mysite.com/httpdocs/public/
<Directory /var/www/vhosts/mysite.com/httpdocs/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>

XAMPP apache server not using the ports I desire, not certain why

So, I've been setting up this HTTP server for a school project that has to be able to maintain multiple domains through virtual hosts. Using XAMPP I have my server set up, I thought I'd done it properly but perhaps not.
I had heaps of issues with not being able to listen to a port, to solve this I used (in httpd.conf under apache/conf/)
Listen 0.0.0.0:8080
ServerName localhost:8080
If I used 80/81/8080/321/any combination that did not have the prefix 0.0.0.0 it told me the port could not be listened or whatever (sorry, a little rusty with my syntax).
I set up my first virtual host up like so (under apache/conf/extra/httpd-vhosts.conf):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "H:/xampp2/xampp/htdocs"
ServerName localhost:8080
<Directory "H:/xampp2/xampp/htdocs">
Option Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I thought this seemed all good and well and I don't believe I've modified anything else. To me, I would expect that this means my Apache server would use port 8080 for the server? However, when I start Apache in XAMPP it states quite clearly
Apache started [Port 80]
Why would this be port 80?
In conjunction, localhost:8080 doesn't navigate me to the documents, but localhost:80 or localhost do. I presume that this just means it's still on port 80. I've tried resetting my computer and XAMPP.
If you need any more information, please let me know. I tried following guides such as this one: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/
Cheers.
Oh, I also edited my Windows HOSTS file; it looks like so:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost:8080
Edit: New error... Now getting this when I init, doesn't seem to be affecting it though:
ERROR: Status Check Failure [3]
This program must be run from your XAMPP root directory.
It is being run from teh root directory as far as I can tell.
Ok Im not advanced in this area either. However after much playing around with XAMPP and following a few different guides I got mine working.
The Host under drivers seems abit weird. I declared mine as:
127.0.0.1:8080 test.localhost.com
127.0.0.1:8080 test2.localhost.com
Back up you Xampp, then extract a clean install to C: - Just because that Status check failure sounds like bad news.
!Remember to run setup_xampp.bat from the xampp directory and install the apache service!
Then under you httpd.conf add:
ServerRoot C:\xampp\apache
Listen 7070
Listen 8080
Listen 9090
Apache might not like that at first but meh.
The ServerRoot may already be declared above the Listen spot so just double check.
After that head to C:\xampp\apache\conf\extra.
Edit the httpd-vhosts.conf.
Under the section Name-based virtual hosting add:
NameVirtualHost *:7070
NameVirtualHost *:8080
NameVirtualHost *:9090
There will be a couple of examples of virtual hosts below that. Add:
<VirtualHost *:7070>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR1"
ServerName test.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR1">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:9090>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR2"
ServerName test2.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR2">
Allow from all
</Directory>
</VirtualHost>
Not the double slash in the Directory tag. Now ensure there is an index.html under each of those directories. Restart the apache (Stop, start).
I cant navigate to the test.localhost.com URLs, probably due to the fact they are terribly wrong in the HOSTs config. Though I can connect to 127.0.0.1:7070, 127.0.0.1:9090 and access the webpages from there.
Also 127.0.0.1:8080 connects me to the xampp welcome panel that localhost used to connect you too.
Hope this helps and good luck!
I'm pretty sure that saying 'listening on port 80' is hard-coded into XAMPP, regardless of the port you use. Thus, your code should work fine.
In my .conf file, it just says "listen 80" instead of Listen 0.0.0.0:8080
Cheers.

XAMPP (WIN7) port change and vhosts

I've decided to change the ports for Apache to clear up some conflicts with other applications, and maybe even give IIS a shot in the future. I've run into the problem described below.
The basic context:
WIN 7 x64
XAMPP 1.7.4 (Apache 2.2.17, MySQL 5.5.8, PHP 5.3.5)
So I've changed the default Apache port from 80 to 8080, by changing this in the httpd.conf:
Listen 8080 (was Listen 80)
ServerName localhost:8080 (was ServerName localhost)
In my vhosts file I have:
NameVirtualHost 127.0.0.1:8080
And several virtual hosts defined like this:
<VirtualHost 127.0.0.1:8080>
DocumentRoot "somepath"
ServerName servername
<directory "somepath">
usual stuff here
</directory>
</VirtualHost>
When I try to access the virtual host using the servername defined above it does not work without explicitly specifying the port:
servername:8080
It would also seem that the port defined in the vhosts file does not make any difference, whatever I tried (80, 8080, nothing), it allways requires the port to be given with the server name.
phpinfo() says:
SERVER_PORT: 8080
Apache error logs do not show any errors.
I guess I'm wondering if this is normal behaviour, or there is something I overlooked.
The 80 port is default for browsers so that's why you don't need to access servername:80. In your case it's normal to acces server like this : servername:8080
If your want to access localhost without specify the port number in the URL http://localhost instead of http://localhost:8080.
Open Xampp Control Panel
Go to Config ► Service and Port Settings ► Apache
Replace the Main Port value ​​with 8080.
Save Service settings
Save Configuration of Control Panel
Restart the Apache Server