Nginx and Apache running at same port - apache

there are projects running on apache and nginx.
as workaround, I set apache to run at port 80 while nginx at port 8000
How can I make nginx and apache to run the applications at similar port 80?
here is a simple scenario
myserver.com/apache1
myserver.com/apache2
myserver.com:8000/nginx1
myserver.com:8000/nginx2
is it possible to set a rule that if requests are for /nginx1 or /nginx2, apache will transfer request to nginx on port 80? or vice versa?
thanks.

base from reply of alvits and Kashyap, I have no other choice but to keep on setting both webserver to different ports

Related

apache proxy tcp traffic

I have a weird problem.
I have http traffic coming in on port 80 that is managed by my vhosts file to proxy to internal web servers but I also have tcp non http traffic coming in on port 80 that needs to be proxied to another internal server on port 80.
I have tried to use proxypass but all that did was proxy http traffic just fine but didnt work on the non http traffic.
I have tried mod rewrite rules to try and isolate the source ip address of the non http traffic and create a rule to proxy it to my other internal host but that didnt work either.
I am using windows with apache and would prefer to use apache to achieve this if possible.
As per this Stack overflow thread- Apache is not an ideal tool for proxying TCP connections.
StackOverlow-how-to-setup-a-reverse-proxy-on-several-ports-tcp-udp

How to change default 80 port to my tomcat 8080 for my domain name

I am using tomcat on Linux centOs server. I want my java application is working fine on mydomain.com:8080. I want that my when some one hit the domain mydomain.com it automatically move to my java application.
Changin server.xml didm't worked for me. as i am also having apache2 on the server
I guess you have an apache server in port 80. I you do not want to remove apache and change directly the tomcat port ( see comments), you will need to redirect all traffic from port 80 to port 8080.
This can be done using tomcat connectors. They are plugins to connect web servers with Tomcat. When a HTTP request arrives, the plugin checks is it has to be redirected, connects to tomcat and returns the response to server
In the case of apache is needed to install mod_jk. In the link you can see the configuration

redirect/listen to port 8080 if 80 is unreachable, apache to lighttpd

i am running apache and lighty on different ports and want to redirect if apache is down. Do i have to use iptables ?
mod proxy_http is enabled, anything to enable something in lighty?
Are there any suggestions?
edit:
FORWARD chain ?
You should use something like haproxy or lighttpd or nginx in front of Apache, and configure any of them to send the request to other backend hosts/server instances if Apache is down. (Apache has modules for this, too, so you could run Apache in front of Apache.)

How to change chef nginx default http port 80?

I tried to install apache on a machine that chef-server was installed. Apache could not start up due to the occupation of port 80 by chef nginx. If I want to let apache use port 80 as default, is it possible to change chef nginx default http port to another one?
I found a solution on the Internet to set virtual host on both apache and nginx, but they need a different FQDN as server name. My machine uses an IP instead of FQDN, so I need to change the default HTTP port for chef nginx.
I tried to add /etc/chef-server/chef-server.rb with the following content:
nginx['non_ssl_port'] = 9898
Then I ran 'chef-server-ctl reconfigure'. It didn't work.
Can anyone help on this? Thanks.
Updated
My information was wrong regarding changing the chef server settings.
The settings should be added into /etc/opscode/chef-server.rb for Chef12. After chef-server-ctl reconfigure, nginx's HTTP port is changed to 9898.
Thanks.
Here is how to change the port. Edit /etc/opscode/chef-server.rb
nginx['non_ssl_port'] = 10080
nginx['ssl_port'] = 10443
nginx['url'] = "https://<YOUR URL>:10443/"
and adjust your local ~/.chef/knife.rb to read
chef_server_url 'https://<YOUR URL>:10443/organizations/<YOUR ORG>'
But currently there is a bug in Chef that prevents the embedded nginx to run on a non standard port: https://github.com/chef/chef-server/issues/50
The settings should be added into /etc/opscode/chef-server.rb for Chef12.
After chef-server-ctl reconfigure, nginx's HTTP port is changed to 9898.

Apache is listening on a different port, but how do I get it so I don't have to type in the port number?

I am running IIS and Apache HTTP Server side-by-side on my localhost machine, and Apache is listening on a different port (port 81). IIS is listening to port 80. However, I can only get to my virtual domains for Apache if I type in that port number. So for instance:
http://virtual.myvirtualdomain.com:81
http://virtual.myvirtualdomain2.com:81
How can I make it so Apache automatically knows it is port 81, and does not force me to type in the port number?
EDIT:
The answer appears to be that I need to redirect IIS to Apache. Can anyone provide clarification on how that is done with IIS 5.1?
It's not a matter of telling Apache, it's a matter of the browser knowing what to connect to. You're either going to have to have IIS redirect to Apache, or give up.
You have to type in the port number so your client knows where to connect to. This has nothing to do with the server.
On Unix systems you might be able to modify your /etc/services to list 81 as port for http. But that would effectively disable access to all websites that are located on port 80.
Alternatively you can configure your IIS on port 80 to locally proxy requests for the sites which are on apache. Then all clients would ask the IIS for a page, which would make a local connection to port 81.
I did some more research and it turns out that you can't redirect IIS 5.1 to Apache because that would require multiple Web sites (setup as redirects to the virtual hosts on Apache on port 81). This is because IIS 5.1 on Windows XP Pro can't do multiple Web sites (running at the same time without the scripting hack). Oh well.
How about you swap it? Make Apache listen on port 80, IIS on port 81 for whatever you need and have Apache redirect? Apache shouldn't be restricted to the same one-website per machine that IIS 5.1 is.
You can't. The 81 is telling your browser where to look for Apache.
You can't.
It's the job of your web client to specify the port, and until you do specify that port it won't even reach Apache.
What you could potentially do is have IIS also listen for the same HTTP/1.1 virtual hosts, and then arrange for it to issue a 302 Moved redirect to send your browser to the right port number.
Alternatively, run a second IP address on your machine, and bind IIS to the original IP address and Apache to the second. That way you don't need to use different ports at all.
There is no way to do exactly what you ask. About the only way would be to configure IIS -- for the virtual domains being served by IIS -- to forward to Apache on port 81. With this configuration, the client would not be aware that their requests were passing through IIS on their way to Apache. A little less efficient, but it would solve your needs.
When an url is typed, there is a certain port that the browser has to use to connect to the site. 80 is the default port that the server checks. If you need to connect to any other port via a browser, you would need to have the port number in the url. It is not apache that is forcing you to type 81, but rather your browser because it is set to use 80 as the port when a port number is not specified.
If you were to change apache's port to 80 and IIS port to 81, then you be able to connect to apache without the port number but you will need to use the port number when using the IIS webserver.
Not sure what the others idea is behind using apache to redirect to IIS. It sounds like to me that if you make an entry in httpd.conf of apache for IIS directory, then you be using apache to connect to the directory, not IIS.
You could set up a domain and have it connect to apache via port 81. That is one way to hide the port number (might be not true. I have never tried apache on port other than 80).