Getting HTTPD to respond regardless of what address was used to get to it.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting HTTPD to respond regardless of what address was used to get to it.

2,765 Views
admin
Specialist II

Hello,

 

I have successfully installed the httpsrv demo application, and the web server works when I go to it directly. IE: MQX is configured with the ip 192.168.2.50, and when I go 192.168.2.50 in my browser I get the MQX web server as expected.

 

However, if I forward an external port on my router/gateway to point to the MQX board  (for example my_external_hostname:88 -> 192.168.2.50:80), the MQX http server refuses to respond when I go to my_external_hostname:88 in my browser. I'm pretty sure the port forwarding is set up correctly (I've done this hundreds of times).

 

I asume the MXQ http server is configured to only respond if the request was directed to it's exact IP, and it doesn't realize I want it to respond even if a different (the external) IP address or hostname was used to get to it. I know full-fledged web servers have settings like this. How do I make the MQX http server respond to any requests?

 

This line:

#define HTTPDCFG_DEF_ADDR               INADDR_ANY     // default listen address

seems to indicate that it should be operating how I want. But I can't see any other options that might help me.

 

Any help is appreciated.

 

Thanks,

 

Brad

Labels (1)
Tags (2)
0 Kudos
17 Replies

1,418 Views
vallinaths
Contributor II

Hi

  I am facing same issue when there is a router in between the internet to the MQX device .

My Mqx device Ip:192.168.10.2 port :81

On the router added the virtual router : to forward the request from port 81 to private LAN port 81

On the private LAN able to reach the webpage  by http://192.168.10.2:81

But using a router by using public ip address is not able to reach somewhere http request is getting discarded .[ http://106.206.193.173:81/]

Please let me know any other setting to made on the configuration .

please any inputs can be provided

0 Kudos

1,418 Views
vallinaths
Contributor II

Hi

  I am facing same issue when there is a router in between the internet to the MQX device .

My Mqx device Ip:192.168.10.2 port :81

On the router added the virtual router : to forward the request from port 81 to private LAN port 81

On the private LAN able to reach the webpage  by http://192.168.10.2:81

But using a router by using public ip address is not able to reach somewhere http request is getting discarded .[ http://106.206.193.173:81/]

Please let me know any other setting to made on the configuration .

0 Kudos

1,418 Views
madifazio
Contributor III

Hello Brad

 

Httpd server listening on port 80. Check that requests (my_external_hostname:88made from the browser are being properly routed.

You have accessed the server from the same subnet? or from outside?

0 Kudos

1,418 Views
admin
Specialist II

I have external port 88 maped to internal port 80 (to the MQX device's IP). I've done it even with 80 mapped to 80 and get the same result. I'll just use 80 always from this point on to avoid the confusion.

 

The MQX device is on the internal (192.168.2.0/24) network. When other devices on the same (internal) network and same subnet access the http server, it's fine. 

 

The gateway does NAT to connect all of the 192.168.2.0/24 devices to the internet. I have the external port 80 on the gateway's external interface (say gateway.example.com) mapped to forward to port 80 on 192.168.2.50 (the MQX device on the internal network).

 

If I try to connect to the MQX server by typing gateway.example.com, the MQX http server refuses to respond. Would this be a problem relating to the request coming from a different subnet, like you alluded to?

 

Thanks,

 

Brad

0 Kudos

1,418 Views
madifazio
Contributor III

If you are using CW10, go to the menu RTCS->Socket Sumary to see which one is listening for http requests. Maybe this helps.

0 Kudos

1,418 Views
admin
Specialist II

There's just one open socket. It's apparently for any IP, port 80.

 

I beleive the HTTP server is throwing out the requests, because of the "Host" field in the HTTP Request from the browser. My router/gateway is doing it's job and forwarding my packets along to 192.168.2.50:80 (my MQX device), but since the router doesn't touch the HTTP Request, the HOST field of the HTTP request is going to say some other address. To me, it seems that httpd in MQX doesn't like this.

 

Can anyone confirm this, or tell me how to get around it?

 

Brad

0 Kudos

1,418 Views
admin
Specialist II

Okay, I found the "HTTPD_DBG_LEV" definition to turn on HTTP logging to the serial terminal. Is there somthing similar fro TCP or RTCS in general?

0 Kudos

1,418 Views
amleng
Contributor IV

Brad,

 

Did you find any solution for your problem? I have exactly the same problem as yours. I found NAT_init() in the RTCS manula but I'm not sure if it's related to this issue. I'll appreciate if you give me any hint. Thanks

0 Kudos

1,418 Views
brad_ci
Contributor II

I never did find a solution. 

 

I think that NAT init function is just for running NAT on the device itself. 

 

If you find a solution, be sure to post it! :smileyhappy: I can't beleive that we're the only ones to run into this problem. I would have though it'd be fixed by now. 

 

Brad

 

Edit: whoops! Replied with my work account. Either way, I'm the OP.

0 Kudos

1,418 Views
Jeinstei
Contributor II

This really sounds like an interesting issue. I wonder where it is losing the http request. That question about logging would be interesting to see.

0 Kudos

1,418 Views
dspNeil
Contributor III

I have no issues running an HTTP server on MQX 3.8 behind my gateway router (forwarded port 80 to my board's IP).

 

In addition to enabling RTCSCFG_ENABLE_GATEWAYS, have you also tried to enabling RTCSCFG_ENABLE_VIRTUAL_ROUTES?

 

Here are my RTCS configs in user_config.h:

#define RTCSCFG_ENABLE_ICMP 1
#define RTCSCFG_ENABLE_NAT 1
#define RTCSCFG_ENABLE_UDP 1
#define RTCSCFG_ENABLE_TCP 1
#define RTCSCFG_ENABLE_STATS 0
#define RTCSCFG_ENABLE_GATEWAYS 1
#define RTCSCFG_ENABLE_VIRTUAL_ROUTES 1
#define FTPDCFG_USES_MFS 1
#define RTCSCFG_ENABLE_SNMP 1

0 Kudos

1,418 Views
David_Wu
Contributor III

have you tried to build for Int_Flash_Release - this works for me on a TCP conncection between different subnet. But Int_Flash_Debug did not work - even I tried following settings:

 

#define RTCSCFG_ENABLE_VIRTUAL_ROUTES 1
#define RTCSCFG_ENABLE_NAT 1 

 

But I run into another issue - If I enable DHCP with  Int_Flash_Release then once it sends a broadcast DHCP request message the system hangs. (see my post https://community.freescale.com/thread/114780

 

0 Kudos

1,418 Views
dspNeil
Contributor III

David,

It's interesting that your Release build works but your Debug does not. Did you recompile the BSP, PSP, RTCS libraries in "Release" mode and "Debug" mode respecitvely? If you change something in user_config.h, you have to rebuild the libraries for each build mode. My build works fine in either Debug or Release. I've had some issues with timeouts in the TCP/IP stack, so I could forsee the extra time required for "Debug" could overrun some timeouts... It's a long shot, but could be a last resort to check. You might also want to try different levels of optimization for Debug until you find the level at which it no longer works. That could possibly tell you what the compiler is doing differently that mkes it work.

 

Did you also set:

#define RTCSCFG_ENABLE_GATEWAYS 1 

 

I have no experience with MQX and DHCP; I make my customers use static addresses!

0 Kudos

1,418 Views
David_Wu
Contributor III
Hi dspNeil,I did recompile BSP/PSP/RTCS/MYproject in that order every time I change user_config.h. It is a surprise for me to notice the differences in Debug and Release mode in this matter.  Timing might matters but it should not make it hang (for DHCP broadcast in Release mode)or reject a TCP connection in Debug build.I will try to adjust the debug level - thanks for the suggestion.FYI - I had the following settings as well in user_config.h#define RTCSCFG_ENABLE_IP_REASSEMBLY 1#define RTCSCFG_ENABLE_IGMP          0#define RTCSCFG_ENABLE_ICMP          1#define RTCSCFG_ENABLE_UDP           1#define RTCSCFG_ENABLE_TCP           1#define RTCSCFG_ENABLE_GATEWAYS      1#define FTPDCFG_USES_MFS             0#define RTCSCFG_ENABLE_SNMP          0#define SHELLCFG_USES_MFS            0#define RTCSCFG_IPCFG_ENABLE_DHCP    1

 

0 Kudos

1,418 Views
dspNeil
Contributor III

Just to be clear, you have to change the Debug/Release mode for EACH library before recompiling. I wasn't sure if you picked up on that.

 

Other than that, you're beyond my experience! Good luck!

0 Kudos

1,417 Views
David_Wu
Contributor III

I did change it using "build configurations" -> "set active" - > 1 Debug/ 2 Release- otherwise I would not be able to link - at the moment I am trying to adjust the compile options - I see the main differeneces for Debug and Release are:

 

for Debug model: 

-opt level=1

-define _DEBUG=1

 

for Release model: 

-opt level=4

 

 I will try -opt level=2 for Release model and see if it resolves the DHCP broadcast request issue I had.

0 Kudos

1,417 Views
David_Wu
Contributor III
updates:It seems there is no route back to the host that makes the connection. I got the error is:TCP: TCP_Send_IP_packet: errno 1510 on IP_send.If I change the netmask to accommodate two subnets then the TCP connection works. Further investigation indicates that it looks like MQX did not support ICMP redirect messages from gateway.

 

0 Kudos