Welcome! Log In Create A New Profile

Advanced

NGINX and WebServices WSDL Reverse Proxy

Posted by giandf 
NGINX and WebServices WSDL Reverse Proxy
November 25, 2016 10:21AM
Hello,

I have a server running Tomcat where it runs a WebService application on port 8080. To all external users, they will access the WebService on port 443 where Nginx will proxy reverse to port 8080. So, I have created the following configuration:

server {
listen 443;
server_name supermercado.cf;
ssl_certificate /.../certificate.crt;
ssl_certificate_key /.../certificate.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/supermercado.cf.access.log;
location / {
proxy_pass http://supermercado.cf:8080;
sub_filter '<a href="http://supermercado.cf:8080/' '<a href="https://$host/';
sub_filter_types text/css text/xml text/css;
sub_filter http://$host:8080 https://$host;
sub_filter_once on;
}
}

As you can see, I have used the proxy_pass directive to redirect all 443 traffic to port 8080 and I used a few sub_filter to replace the URL on the WebService page. The attached picture shows the Service URL, where the Address parameter is doing the right substitution by replacing the http://supermercado.cf:8080 URL by the https://supermercado.cf. However, the WSDL URL does not get replaced and keeps showing the URL pointing to port 8080.

Also, on the bottom of the picture you will see the same happening for the ?wsdl URL where the location also points to port 8080.

So, How can I setup NGINX to show all URLs pointing only to the HTTPS protocol?

Thanks in advanced,
Giancarlo
Attachments:
open | download - NGINX WebService TPROXY.png (124.4 KB)
Re: NGINX and WebServices WSDL Reverse Proxy
November 25, 2016 10:26AM
You need to adjust the tomcat application (configuration) with proxy settings.

https://www.mkyong.com/nginx/nginx-apache-tomcat-configuration-example/
http://webapp.org.ua/sysadmin/setting-up-nginx-ssl-reverse-proxy-for-tomcat/

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NGINX and WebServices WSDL Reverse Proxy
November 25, 2016 10:52AM
Hello,

I tried the the configuration you mentioned on the second link (http://webapp.org.ua/sysadmin/setting-up-nginx-ssl-reverse-proxy-for-tomcat/) and it worked perfectly.

One more question: Would be possible to remove the 443 from the URL? Now it is showing like this:

https://supermercado.cf:443/Supermercado/Service

Thank you again,
Giancarlo
Re: NGINX and WebServices WSDL Reverse Proxy
November 25, 2016 01:08PM
It looks like tomcat is adding this as a reply to the clients and should be a setting.
Or your subfilter is doing this.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NGINX and WebServices WSDL Reverse Proxy
September 13, 2023 08:32AM
use this:

location / {
proxy_set_header Host $host;
proxy_pass http://supermercado.cf:8080;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready