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

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.)

Related

Apache and Yarn ports

I want to configure both apache and yarn servers on the same machine. Default web port is 80 and 443 for ssl as far as I know.
Is that possible for both services to share the same ports? What I need is:
http(s)://example1.com - go to apache server
http(s)://example2.com - go to yarn
I know I can configure it so I call:
http(s)://example1.com:3000 or other port. It's not intuitive for users however.
Or... make htaccess rule to redirect example1.com:80 to example1.com:81 for example? Or somehow internally redirect from apache to yarn...? :)
I'm pretty newbie in configuring servers... I always used default settings and vhosts and it was just enough. In fact I've never work with yarn at all so any advices will be appreciated.
Solved:
apache in vhosts configuration is redirecting specific domain traffic from :80 to :3000 and node is run on 3000 port.
In my opinion you can using haproxy or squid proxy, to loading balancing, or you can set on domain server to set pointing the domain, but you must set other port on of app, on this case we must try to easy access without type the port on the address bar

Nginx and Apache running at same port

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

Apache route subdomain to nginx on port?

I have a server running CentOS 7 that has an Apache web-server running on port 80. I am also using a common open-source Git project called GitLab, which uses the nginx web-server instead of Apache. I have configured GitLab's nginx to run on port 4444.
I have a subdomain "git.mydomain.com" that I would like to forward to "mydomain.com:4444" however I would like the URL to continue saying "git.mydomain.com".
I belived that I need to have an Apache VirtualHost file, however I'm not sure what to do.
Is this possible? If so, how can I do so?
Thanks
You would indeed need a git.mydomain.com VirtualHost with a proxy/reverse proxy directive. See https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

how to redirect apache port 80 to jetty port 8080?

I have a VPS server with a domain example.com, with apache2 listening port 80
Then, I have a web app in jetty server (running with mvn jetty:run), listening in port 8080
When I type example.com in a browser, I get a apache example page "it works!"
If I write example.com:8080 I get my webapp
Question is simple, how can I redirect for when I write example.com so that I get to my webapp?
I cant change port jetty to 80, its error.
command "sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080" does not anything effect
So, how can i make apache redirect 80 to 8080? in sites-enabled/default-000?
Please explain carefully, I'm a newbie with systems ;(
Thank you
EDIT
I solved it with this:
http://czetsuya-tech.blogspot.com.es/2012/07/how-to-port-forward-apaches-80-to.html#.VImt1XvyOPU
But last line:
RewriteRule ^/(.*) ......:8080/0,81 € [P,L]
Makes error at restart apache
I deleted it and works fine. Any problem with this? What is RewriteRule?
Using IPTABLES is one possible solution. I don't know much about IPTABLES - but there are a lot of tutorials out there, like this one: http://proghowto.com/iptables-redirect-port-80-to-port-8080
I don't know if that works if you have a running daemon (apache) on the destination port.
The other solution is to use a proxy module in apache to pass requests through to your webapp. On Linux only root users are allowed to use ports below 1000. On Windows you should be able to simply change the port in the jetty configuration.
There are two tutorials I often use, they apply to apache and tomcat but that makes no difference for the apache side:
https://confluence.atlassian.com/display/DOC/Using+Apache+with+virtual+hosts+and+mod_proxy
https://confluence.atlassian.com/display/STASH/Integrating+Stash+with+Apache+HTTP+Server
This is quite a common setup. Also there is almost no performance impact due to the proxying. Not that a user would notice anything.

How do I redirect from Apache to Tomcat?

I'm working on my first Java site. I'm running Apache Tomcat on port 8080, and Apache HTTPD on port 80. The current URL that I can access the site at is (for example) 123.4.5.6:8080. I want to remove the port number from the URL before I point the domain at the new IP.
At the moment I am only using Apache for phpmyadmin, however I plan on using it for CGI scripts and other stuff once I figure out mod_jk etc... So I don't want to change Tomcat's port to 80 and turn off Apache.
I hope this makes sense.
The correct way to do things is to leave Apache at 80 and Tomcat at 8080 and use a plug in (preferably mod_proxy) to proxy Tomcat from Apache. mod_proxy would only take you 10 minutes to set up.
This how-to is very simple to follow.
The usual way this is done, as you already mentioned, is to use mod_jk from Apache HTTPD to forward that content that you want to be processed by Tomcat.
There is a Quick HowTo at tomcat.apache.org. You need to do the following:
Copy mod_jk.so into the appropriate modules directory for Apache HTTPD.
Create a configuration file workers.properties
In Apache HTTPD's httpd.conf, add a section to configure mod_jk.
Ensure that Tomcat is configured to accept the mod_jk protocol, which is usually on port 8009.
The lines in httpd.conf with JkMount:
JkMount /examples/* worker1
tell Apache HTTPD which requests are to be forwarded to Tomcat.
Both the helpful answers above are good, but I much prefer mod_proxy over mod_jk. There's no extra installation to do for mod_proxy, unlike mod_jk, and the setup is much easier. mod_jk gives you more control over detailed tuning of Tomcat parameters, but if you just want a simple redirect from Apache to Tomcat, mod_proxy is the way to go.
If you want static content to be served by Apache instead of Tomcat you should use mod_jk : http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html
And what about SSL - if we want Apache to handle HTTPS, because it is faster then java/Tomcat?
you should configure your tomcat using this link. for tomcat 7
http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html