System: ubuntu 12.04LTS
I use Apache as Proxy server for my Tomcat7 webserver.
For Apache as Proxy I activated the modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
Then I edit the /etc/apache2/sites-available/default as:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ProxyRequests Off
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Location "/">
Order allow,deny
Allow from all
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I am using Websockets so I need to enable them. How can I do that in the Apache Proxy server?
Chrome shows me this error:
WebSocket connection to 'ws://www.myapp.com/socket/848df2e62fcf93e1b3?X-Atmosphere-tracking-iā¦Date=0&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true'
failed: Unexpected response code: 200
You are seeing that error likely because your version of Apache does not support HTTP 1.1. To configure your Apache to support websockets, try following this:
https://serverfault.com/questions/290121/configuring-apache2-to-proxy-websocket
EDIT: Removing remainder of post as it is off subject
Related
We've got a Java server running on Tomcat8 on AWS ElasticBeanStalk. The project contains an AngularJS webapp as frontend.
Our frontend webapp is accessible by www.domain.com/webappName. I put a .conf file in .ebextensions/httpd/conf.d in my root directory.
Here's the content of my conf.d (rule redirect to a new url with new version of frontend, in Angular7)
<VirtualHost *:80>
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/webappname/index\.html
RewriteRule ^webappname/index\.html(.*)$ https://redirect-domain.com/$1 [R=301,L]
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://localhost:8080/ retry=0
ProxyPassReverse / http://localhost:8080/
ProxyPreserveHost on
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
</VirtualHost>
But rewriting not working. I tested my rule in localhost and on an online simulator and it was working fine. But when we deploying our War file on AWS ElasticBeanStalk, it's not working.
Do you know why ? It's look like the configuration file is bypassed. I tried with AllowOverride All but it doesnt work.
Our ElasticBeanStalk is running with Tomcat8, Java8 and Apache 3.3.2.
I'm trying to make grails app run under two different domains - test.com/myapp and test.org/myapp. host in Config.groovy url is pointing to https://test.com/myapp What happens is when I go to test.org/myapp it goes properly to the home page and when I'm trying to login it redirects to the first domain. I guess it's something to be with spring security and path generating. What are my options in order to fix that?
Here is my myapp.conf but if you need additional data pls let me know in comments
Alias /.well-known/acme-challenge/ "/var/www/html/certbot/.well-known/acme-challenge/"
<Directory "/.well-known/acme-challenge/">
Options -Indexes -MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName test.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:443>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/html/honeypot/
RewriteEngine On
php_flag engine off
RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo
JkMount /* worker1
JkUnMount /myapp/files/* worker1
Alias "/myapp/files" "/var/www/myapp/files"
<Directory "/myapp/files">
allow from all
Options -Indexes
AllowOverride None
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/test.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/test.com/chain.pem
SSLProxyEngine on
ProxyPreserveHost On
ProxyPassMatch ^/myap(.+)$ !
ProxyPass / https://myserver.com/
ProxyPassReverse / https://myserver.com/
</VirtualHost>
UPDATE
grails.serverURL = https://test.com/myapp
Perhaps you should post your configuration for spring-security. Assuming it is that problem, there are different ways to tackle it. One is that you can set external configuration in Grails applications using grails.config.locations (see http://docs.grails.org/2.5.4/guide/single.html#configExternalized) and then you override the application settings for Spring Security within an external file on your server that the grails.config.locations is referencing.
This allows you to manage the application configuration separately, but deploy the same war. You could then manage the external files by some configuration management system, such as Puppet.
I am working on Tomcatcat Clustering with Apache server on Ubuntu14. I did Tomcat Clustering successful and integration with Apache server as well.
In Apache server I did the virtual hosting as well something like following code.
<VirtualHost *:80>
ServerName myexample.com
ServerAdmin webmaster#myexample.com
DocumentRoot /var/www/myexample.com/public_html/
ServerAlias www.myexample.com
JkMount / balancer
# Error page is just the index telling about the situation of not being connected
ErrorDocument 404 /index.html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
So when I request myexample.com it send the request to balancer and balancer further redirect this request to one Tomcat Worker. My worker.properties file looks like this.
# Define 1 real worker named ajp13
worker.list=balancer,stat
# Set properties for worker named ajp13 to use ajp13 protocol,
# and run on port 8109
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8109
worker.tomcat1.lbfactor=10
worker.tomcat2.type=ajp13
worker.tomcat2.host=localhost
worker.tomcat2.port=8209
worker.tomcat2.lbfactor=10
worker.tomcat3.type=ajp13
worker.tomcat3.host=localhost
worker.tomcat3.port=8309
worker.tomcat3.lbfactor=10
worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3
worker.stat.type=status
Now the problem is whenever I request myexample.com, request is redirect to Tomcat Root folder and shows the Root folder content. I have one web application(helloworld) inside webapps folder of each tomcat instance.
So my question is how can I configure Tomcat or Apache so that request should redirect go to helloworld instead of Root folder.
I have a server with CentOS and zpanel installed. Zpanel installed "Apache Httpd" along many other modules. I have been hosting multiple domains without any issue.
I have two issues:
Remove port 8080 and direct all calls to 80.
Appropriate domain for each tomcat app, as well as my existing sites running independently on Apache Http.
I installed apache tomcat 8 and deployed multiple applications and I can access my applications like
http://example:8080/app1
http://example:8080/app2
http://example:8080/app3
What I want is that my tomcat apps are mapped to my domains, such that
http://example:8080/app1 => http://www.app1.com
http://example:8080/app2 => http://www.app2.com
http://example:8080/app3 => http://www.app3.com
I did tried this tutorial which somewhat does trick but not exactly what I want. i.e. after performing the steps he mentioned when I opened my example.com it redirected to my tomcat app like: example.com/app1. [It did removed 8080 and redirected to correct app] BUT if the app from the end is changed i.e. app1 is changed to someother project that is been hosting by tomcat then that project is opened.
Edit:
My virtual host file is
# DOMAIN: app1.com
<virtualhost *:80>
ServerName app1.com
ServerAlias app1.com www.app1.com
RewriteEngine On
RewriteRule ^/$ app1/ [R=301]
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /app1 http://localhost:8080/app1
ProxyPassReverse /app1 http://localhost:8080/app1
ErrorLog "/var/zpanel/logs/domains/zadmin/app1.com-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/app1.com-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/app1.com-bandwidth.log" common
</virtualhost>
Update 1
I tried this as well, but of no use. Am I missing something? please guide.
Have you configured properly your http server ?
For example in your apache2.conf or httpd.conf
#LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName www.example.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://example.com:8080/app1
ProxyPassReverse / http://example.com:8080/app1
ProxyHTMLURLMap / /app1/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
After 2 Days of hard search and lots of tests I was finally able to map my domain to tomcat app. Many thanks to these two guides mod_jk installation and vhost/httpd/tomcat
I have a tomcat 6.0 web server on my server machine.now i created a glassfish server on the same machine. for avoid port conflict i just change glassfish port to 8081. now how can i access my web applications on both glassfish and tomcat from different DNS name.
Depends on your DNS/server setup.
You could use Apache and reverse proxies:
<VirtualHost *>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://0.0.0.0:8081/
ProxyPassReverse / http://0.0.0.0:8081/
ServerName glassfish.server
</VirtualHost>
<VirtualHost *>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
ServerName tomcat.server
</VirtualHost>
Or you could use your DNS. I'm afraid I can't help you with that.