Apache HTTPD VirtualHost issues on port 443 - apache

I'm trying to setup Apache HTTPD to work with Tomcat. Right now I have tomcat up and running and it is working fine (can access the web application by specifying the :8080 in the url). What I want to do is have Apache HTTPD redirect port 80 traffic to 443, have SSL become established, then have it reverse proxy traffic to Tomcat. The port 80 traffic redirect works using the REDIRECT directive (redirecting to https:// www. myregistereddomain.com). For some reason the virtual host directive is not resolving for the 443 traffic. I get an "Invalid method in request \x16\x03\x01" followed by "File does not exist: /usr/local/apache/htdocs/501.shtml" in the apache error_log.
Link pertaining to issue: http://www.noah.org/wiki/Apache2_Invalid_method_in_request_%5Cx16%5Cx03%5Cx01
I have tried change the virtual host to _default_:443 and *:443, but it still throws the same errors. There are no other VirtualHost directives in the httpd.conf file so i'm not sure how it is not resolving to that virtual host on 443. It was initially "www.mydomain.com:443" and then i tried it by "IP:443", but still same errors. Anyone happen to have any idea what is wrong with the setup or any pointers on how to proceed to troubleshoot it?

Ended up just using nginx. Was much easier to setup and get functioning as a reverse proxy.

Related

How to share https connections on port 443 with two different servers

I have a site with two servers, apache2 and Tomcat7.
Apache2 listens to 80, while tomcat7 to 443.
Apache2 is needed to present a Wordpress blog, while Tomcat7 to serve a JSP site.
My virtualhosts scheme in Apache is like this:
http://blog.example.com ---> DefaultRoot for the blog
http://example.com ---> Redirect to https://example.com (where Tomcat listens)
Everything works fine. My original site in JSP always responds in https secure mode, while I have a working Wordpress in my "blog." subdomain.
The problem comes now that I want that blog interact with https (without any ugly 3rd port in the url if possible)
Making Apache2 to listen at 443 will obviously come to a conflict about 'port in use'.
Disabling it in Tomcat7 has no sense as somewhere it has to listen for ssl.
The question for you is: How would you face it?

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

apache redirect to SSL configured site

I am trying to setup a gitlab repository and I am quite new to the web server side of things. My setup is the following:
I have an apache server which is running my main website on port 8080.
I have the gitlab configured with SSL and Nginx and running on port 2443.
At the moment, the gitlab site can be accessed through https://www.example.com:2443.
What I would like to do is setup a redirect through my apache server where if someone comes to http://www.example.com/gitlab or https://www.example.com/gitlab, they get redirected to ``https://www.example.com:2443` (preferably without the web browser text field changing).
Could this be done easily with Apache? Also, since the redirect is to an SSL site, any special things we need to consider?
You can try adding the redirect directive to your Apache VirtualHosts (8080 and 443).
Redirect permanent /gitlab https://www.example.com:2443

SSL redirects user to wrong website on apache

I host 100+ websites on 2 different servers. Some of my clients recently have noticed that when they go to https://theirwebsite.com, if they DONT have SSL on their website, it redirects to the first SSL website in the apache conf file. I did some reading and discovered that SSL websites need their own IP addresses, so i switched the IP addresses of my SSL websites. However, i noticed that the problem is still happening. It's possible that there are still SSL websites that need to be removed or changed in httpd.conf, but is there a way to stop this from happening? Can i find a way to just make websites without https redirect to nothing if https is used?
it redirects to the first SSL website in the apache conf file.
This is because there are 2 sets of virtual hosts you have for apache: 1 that listens to port 80 (non-SSL) and one that listens to port 443 (SSL). Any non-SSL request gets sent to the vhosts that listens to port 80, and any SSL request gets sent to the chosts that listens to port 443. When a request is made for a host that isn't defined in any of the vhosts, it defaults to the "default" vhost, which becomes the very first one that gets defined (e.g. the first one that appears in your vhost file).
In order to prevent this, you can either have a defined SSL vhost for each of your non-SSL websites, or you can create a new "default" vhost in your SSL file that does nothing but redirect to non-SSL:
RewriteEngine On
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R]

lighttpd reverse proxy to apache

I have just started using lighttpd and I am trying to configure it to act as a reverse proxy to an Apache server running on 127.0.0.1 on port 8080. I have multiple wordpress blogs running on the same host
127.0.0.1:8080/blog1
127.0.0.1:8080/blog2
I have just bought a domain name www.mydomain.com and I would like to requests to blog1 to appear like this
www.mydomain.com/article1 even though on my server this translates to 127.0.0.1:8080/blog1/article1
What I am after is an example of lighttpd.conf configuration that will redirect requests from www.mydomain.com that arrive on port 80 to be redirected to 127.0.0.1:8080/blog1.
Can anyone help me?
Update: lighttpd 1.4.46 (released in 2017) has proxy.header which allows limited rewriting of the url prefix when proxying. See lighttpd mod_proxy