What's new

Redirect to local URL by using a name

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Klozzas

New Around Here
Hi all,

I´m running Merlin WRT version 380.61 on my RT-AC68U. I´m new to the Merlin WRT and I hope you can help me out with the configuration here.

I´m running a Plex server on one of my pcs. I want to make the access via web easier for my roommates.
Instead of typing "http://192.168.1.50:32400/web" into the browser I want them to enter just a name like "http://plex.home". (or even without .home)
Then router should forward this name "plex" to the local url "http://192.168.1.50:32400/web"

I think I need to add somewhere a rerouting of this request. But my problem is, I don´t have any know-how of configuring a WRT router.

I hope that one of you can help me.

Thanks in advance.
 
I'd be happy to post an example - but I can't...

@thiggins - what's going on here?

Screen Shot 2016-08-12 at 4.40.39 PM.png
 
You will need to install some form of web proxy (such as nginx or lighttpd) on the router to accept HTTP requests on that port, and redirect them to a different URL.
 
You will need to install some form of web proxy (such as nginx or lighttpd) on the router to accept HTTP requests on that port, and redirect them to a different URL.

Just edit the hosts file over in the etc directory - the host can be resolved there... do the IP and the host from there.

Tried to do a practical, but got the big red box - probably a side effect of some upstream problem mitigation - found that interesting...

weird how that works...
 
Just edit the hosts file over in the etc directory - the host can be resolved there... do the IP and the host from there.
Edit's in the hosts file are not permanent. After the next reboot that change is gone.
You'd have to do it in /jffs/configs/dnsmasq.conf.add
Anyway, you could only point to an IP, not the port number with that method.

Edit: You could add this to /jffs/configs/dnsmasq.conf.add
Code:
address=/view/192.168.1.50
And then use http://plex.view as the url, using /home/ would not work well in a Windows environment, I believe.
Still, this only forwards to port 80 and there's no way to change that with dnsmasq.
 
Last edited:
@sfx2000 I believe this forum and the website suffer from ddos attacks. The site was unreachable to me for a couple of hours yesterday. Then when it was available again, some sort of check run in the browser before the site loaded. Cloudfare protection or whoever is his hoster.
 
Just edit the hosts file over in the etc directory - the host can be resolved there... do the IP and the host from there.

That won't work as he wants the redirection to also redirect to a different port. He needs some form of URL rewrite capability.
 
That won't work as he wants the redirection to also redirect to a different port. He needs some form of URL rewrite capability.

Missed that one - can still do this via dnsmasq.conf, adding the host and port there for redirection..

(might have to check iptables to ensure that the port isn't blocked anywhere)
 
Love to show you an example, but cloudflare keeps popping up...

essentially, you use the address directive in the dnsmasq.conf file, where any URI can be pointed to an IP address, and the port number can be included in that URI
 
I believe this forum and the website suffer from ddos attacks. The site was unreachable to me for a couple of hours yesterday. Then when it was available again, some sort of check run in the browser before the site loaded. Cloudfare protection or whoever is his hoster.

Cloudflare helps out quite a bit, and yes, the site was under (maybe still is?) a heavy DDOS attack...
 
Love to show you an example, but cloudflare keeps popping up...

essentially, you use the address directive in the dnsmasq.conf file, where any URI can be pointed to an IP address, and the port number can be included in that URI

I don't see how that could work. There are no provisions for storing a port number in a DNS lookup. All dnsmasq can do when queried by a web browser is return a resolved IP (or a CNAME that gets ultimately resolved as an IP).

The closest one might do this without the use of a web proxy is by having a port redirection in iptables.
 
essentially, you use the address directive in the dnsmasq.conf file, where any URI can be pointed to an IP address, and the port number can be included in that URI
Hmm, not seeing it myself:

admin@RT-N66U:/# dnsmasq --log-async --address=/home/192.168.1.50:32400

dnsmasq: bad command line options: bad address
 
Have to do the whole URI - so try --address=/plex.home:32400/192.168.1.50

give that a try... and variations of that construct - I'm not in a spot where I can stand up an instance to sort it out much further, but remember, DNS is useful for redirection...

Quick hint - if you have mDNS running on your network (got iTunes for example), using the .local TLD helps out a lot as far as cleaning up situations like this...
 
Nope, still doesn't work.

Using that address statement I can trick dnsmasq into accepting the syntax, but all that achieves is it thinking that "home:32400" is a domain name:

# dnsmasq --log-async --address=/plex.home:32400/192.168.1.50
# nslookup plex.home:32400
Server: 127.0.0.1
Address 1: 127.0.0.1 localhost.localdomain

Name: plex.home:32400
Address 1: 192.168.1.50 micro
# nslookup plex.home
Server: 127.0.0.1
Address 1: 127.0.0.1 localhost.localdomain

nslookup: can't resolve 'plex.home'


So that's no help when you put http://plex.home into a browser:

As far as I can see the PC is only ever going to query the domain part of the URI, and the DNS server is only capable of sending back an IP address. There is nowhere in that process that involves port numbers, let alone dnsmasq being able to magically append /web to the end of the URI in the client's browser.
 
Last edited:
I´m running Merlin WRT version 380.61 on my RT-AC68U. I´m new to the Merlin WRT and I hope you can help me out with the configuration here.

I´m running a Plex server on one of my pcs. I want to make the access via web easier for my roommates.
Instead of typing "http://192.168.1.50:32400/web" into the browser I want them to enter just a name like "http://plex.home". (or even without .home)
Then router should forward this name "plex" to the local url "http://192.168.1.50:32400/web"

I think I need to add somewhere a rerouting of this request. But my problem is, I don´t have any know-how of configuring a WRT router.

ok, let's rewind here a little bit...

Why bother with any of this - the plex client apps discover the server anyways... seems like a much easier solution to me... don't worry about the Web client, or just make them type in the hostname.local:port and go from there.

As long as everyone has iTunes installed, Bonjour will resolve the .local domain for you, and it also helps with service discovery on the LAN (one of the better cross platform things Apple has done)
 
Find a solution with combination of hosts and iptables.

in hosts (/jffs/configs/hosts.add more specifically):
Code:
192.168.1.2 plex.home

Note that dhcp also need to be properly configured so that 192.168.1.2 will not be assigned to any devices.

for iptables (/jffs/scripts/nat-start more specifically):
Code:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.2 -j DNAT --to-destination 192.168.1.50:32400

In this way, plex.home in web browser should be able to access 192.168.1.50:32400, but you also need to the extra `plex.home/web`

It should work but to be honest, I am not sure it is a good one or not as a newbie of Merlin world. Any comments are welcome.
 
It should work but to be honest, I am not sure it is a good one or not as a newbie of Merlin world. Any comments are welcome.
That won't work because plex.home resolves to a local IP address and is therefore not routed. So it never gets as far as the iptables rule.
 
That won't work because plex.home resolves to a local IP address and is therefore not routed. So it never gets as far as the iptables rule.

Yeah, I have to admit you are right. Why I accidentally find it seems to work is that I connected to my Asuswrt-Merlin using VPN from mobile outside. Anyway, thanks for the clarification.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top