For integration tasks, you may need a proxy server. This part describes the configuration of Nginx HTTP-server as a proxy for CUBA application.
Tip
|
If you set up a proxy, do not forget to set cuba.webAppUrl value. |
- NGINX
-
For Nginx there are 2 configurations described below. All examples were tested on Ubuntu 16.04.
For example, your web application works on http://localhost:8080/app
.
Tip
|
Tomcat should be configured as well. |
- Tomcat Setup
-
First, add
Valve
to Tomcat configurationconf/server.xml
, copy and paste the following code:<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" requestAttributesEnabled="true" internalProxies="127\.0\.0\.1" />
and restart Tomcat:
sudo service tomcat8 restart
This is required to dispatch Nginx headers by Tomcat without modifying the web application.
Then install Nginx:
sudo apt-get install nginx
Navigate to
http://localhost
and ensure that Nginx works, you will see Nginx welcome page.Now you may delete the symlink to default Nginx site:
rm /etc/nginx/sites-enabled/default
Next, configure your proxy one of the options selected below.
- Direct Proxy
-
In this case the requests are handled by proxy, transparently passing to the application.
Create Nginx site configuration file
/etc/nginx/sites-enabled/direct_proxy
:link:../../../source/deployment/direct_proxy.yml[role=include]
and restart Nginx
sudo service nginx restart
Now you can access your site via
http://localhost/app
.
- Redirect to Path
-
This example describes how to change the application’s URL path from /app to /, as if the application were deployed in the root context (similar to /ROOT). This will allow you to access the application at
http://localhost
.Create Nginx site configuration file
/etc/nginx/sites-enabled/root_proxy
:link:../../../source/deployment/root_proxy[role=include]
and restart Nginx
sudo service nginx restart
Now you can access your site via
http://localhost
.
Tip
|
Please note, that similar deployment instructions are valid for Jetty, |