# Rewrite links from hardlinked http to https

**URL:** <https://www.ruby-forum.com/t/rewrite-links-from-hardlinked-http-to-https/188161>\
**Category:** NGINX\
**Created:** [May 6, 2010, 6:38pm UTC](https://www.ruby-forum.com/t/rewrite-links-from-hardlinked-http-to-https/188161 "2010-05-06T18:38:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![genesis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/96bed5/32.png) [@genesis](https://www.ruby-forum.com/u/genesis)\
**Post date:** [May 6, 2010, 6:38pm UTC](https://www.ruby-forum.com/t/rewrite-links-from-hardlinked-http-to-https/188161/1 "2010-05-06T18:38:29Z")

</div>

Hello!

I’m fairly new at this, but I’ve googled for days and not been able to  
solve this, so I thought I’d try asking for help.

I am running a jsp-webapp on Tomcat, and want to use nginx as a reverse  
proxy with ssl, in order to access the webapp through https securely  
over the internet.

However, this webapp is not nicely written. Instead of linking normally,  
say to " page2.jsp ", it links to "  
[http://www.example.com:8080/page2.jsp](http://www.example.com:8080/page2.jsp) ".  
I have gotten the reverse proxy to work as I want in the few cases the  
webapp links normally, but I haven’t got nginx to change the url of  
links that is hardlinked to http.

I first started to try to rewrite the webapp, but some http-links are  
generated by compiled .class-files, and I don’t have the source code.

So is there any way to make nginx (or another reverse proxy?) look  
through each page that is transferred and change all links and  
post-url’s from " [http://www.example.com:8080/my/path.jsp?my=action](http://www.example.com:8080/my/path.jsp?my=action) " to  
" [https://www.example.com/my/path.jsp?my=action](https://www.example.com/my/path.jsp?my=action) "?  
That would be very nice, so that I don’t have to try to decompile and  
edit several hundred .class-files.

Huge thanks to anyone that help me!

Posted at Nginx Forum:

> **[Rewrite links from hardlinked http to https.](https://forum.nginx.org/read.php?2,83369,83369#msg-83369)**
>
> Hello! I'm fairly new at this, but I've googled for days and not been able to solve this, so I thought I'd try asking for help. I am running a jsp-webapp on Tomcat, and want to use nginx as a reverse proxy with ssl, in order to access the webapp...

---

<div class="post-metadata">

**Author:** ![genesis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/96bed5/32.png) [@genesis](https://www.ruby-forum.com/u/genesis)\
**Post date:** [May 12, 2010, 9:19pm UTC](https://www.ruby-forum.com/t/rewrite-links-from-hardlinked-http-to-https/188161/2 "2010-05-12T21:19:11Z")

</div>

Hi,

You may have found it by now, but just in case:  
[http://wiki.nginx.org/NginxHttpSubModule](http://wiki.nginx.org/NginxHttpSubModule)

Try this:  
sub\_filter “[example.com:8080/](http://example.com:8080/)” “[example.com/](http://example.com/)”;  
sub\_filter\_once off; # Replace all occurrences

Or maybe:  
sub\_filter “[http://www.example.com:8080/](http://www.example.com:8080/)” “/”;  
sub\_filter\_once off; # Replace all occurrences

Hope this helps,  
GFK’s

Genesis a Ã©crit :
