Forum Discussion
Nginx Reverse Proxy issue for port other than 81
I have a backend tomcat application which runs on port 8080 with IP 192.168.29.141. I am trying to reverse proxy using Nginx for which I have created the below configuration file:
upstream tomcat{
server 192.168.29.141:8080;
}
server {
#listen 192.168.122.28:80;
listen 192.168.122.28:81;
server_name tomcat;
location / {
proxy_pass http://tomcat;
}
}
When I load the page on browser, the page is distorted and I get below error in Browser console:
"Unsafe attempt to load URL http://tomcat/o/classic-theme/images/clay/icons.svg from frame with URL http://tomcat:81/. Domains, protocols and ports must match."
But when I run the nginx on port 80 instead of port 81, everything works fine. Is there anything I am missing in configurations for port other than 80 ?
My Nginx Server IP: 192.168.122.28
Browser screenshot when hit the URL as http://tomcat:81
From what it seems the tomcat page has in its response body links to other content that is still on port 80, so you will need to rewrite the response body:
Module ngx_http_sub_module (nginx.org)
How to Modify Webpage Content on NGINX Proxy Using SUBS and Substitution Module ★ VSYS Tutorials
- shubhankarsoniNimbostratus
Hey Nikoolayy1,
Here Nginx is doing a reverse proxy to my backend application hosted on Tomcat. I can access the application directly when I hit the Application URL and port 8080. The pages are not defined with any ports (like 8080, 80, 443 etc).
Also, when I access via Nginx URL everything works fine with port 80 and 443. idk, what is happening with custom ports, since there is no explicit declaration in my pages anywhere regarding ports specifically. I checked with Apache HTTP server with custom port, but everything was working as expected. I suspect some configuration is missing in my config file of Nginx
I still think it is more with the tomcat going through a proxy not nginx specific issue. You can configure a test version on your app and use 81 port to see if the issue is seen without the nginx when accessing directly on port 81.
svg <track> Unsafe attempt to load URL () from frame with URL () nginx - Google Търсене
Still you can see Load Balancing Apache Tomcat Servers with NGINX Open Source and NGINX Plus | NGINX Documentation as to configure websocket support as well and also just in case add include "/etc/nginx/mime.types;" to the http context but be aware that I think this is only when nginx is a server not reverse proxy but as I said just in case.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com