user7623: I am trying to access my Yun externally.
My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.
I have the below code working internally and now trying to adapt this to work for external (adapted from http://arduino.cc/en/Tutorial/TemperatureWebPanel). 
To access the Arduino Yun over the network I type:
http://XXX.XXX.XXX.XXX:XXXXX/arduino/on

When using this script locally, i.e. myArduinoName.local/arduino/on, the onboard light turns on (and off if URL changed accordingly).
Adapting this working code, I have changed to "noListenOnLocalhost" and put in my port number (XXXXX).  
The code is reached (see below for the response).
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h> 

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(XXXXX);
String startString;
long hits = 0;

void setup() {
  //Serial.begin(9600);

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);


  Bridge.begin();
  Console.begin();


  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  //server.listenOnLocalhost();
  server.noListenOnLocalhost();
  server.begin();

}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  client.println("hello");

  // There is a new client?
  if (client) {
    // read the command
    String command = client.readString();

    command.trim();        //kill whitespace

    client.println(command); // why does this return a full GET request instead of "on"?

    if (command == "on") {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);   
    }

    if (command == "off") {
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);              // wait for a second
    }


    // Close connection and free resources.
    client.stop();
    hits++;
  }

  delay(50); // Poll every 50ms
}

The response I get is (I have replaced my IP and port with X's):

hello
GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX
  Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
  Accept:
  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36
  (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
  Accept-Encoding: gzip, deflate, sdch Accept-Language:
  en-GB,en-US;q=0.8,en;q=0.6

I expected

hello 
on

So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.
I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.
Then tried to restart the device and also a uhttpd restart i.e.:
/etc/init.d/uhttpd restart

I have attempted to access the URL using my mobile phone (i.e. not on the same network).
Any ideas why my request is not being treated as HTTP?

user7623: It works!
The changes to the uhttpd must have done the trick to listen for http traffic on a given IP/port (other than 0.0.0.0:80).
Instead of supplying a port number for the server in the code, I would surmise that the change to the config takes care of it so this, so the port number in code is no longer needed:
YunServer server(XXXXX);
should be changed back to 
YunServer server;

7623: <p>I am trying to access my Yun externally.</p>

<p>My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.</p>

<p>I have the below code working internally and now trying to adapt this to work for external (adapted from <a href="http://arduino.cc/en/Tutorial/TemperatureWebPanel" rel="nofollow noreferrer">http://arduino.cc/en/Tutorial/TemperatureWebPanel</a>). </p>

<p>To access the Arduino Yun over the network I type:</p>

<pre class="lang-none prettyprint-override"><code>http://XXX.XXX.XXX.XXX:XXXXX/arduino/on
</code></pre>

<p>When using this script locally, i.e. <code>myArduinoName.local/arduino/on</code>, the onboard light turns on (and off if URL changed accordingly).</p>

<p>Adapting this working code, I have changed to "<code>noListenOnLocalhost</code>" and put in my port number (XXXXX).  </p>

<p>The code is reached (see below for the response).</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;Bridge.h&gt;
#include &lt;YunServer.h&gt;
#include &lt;YunClient.h&gt; 

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(XXXXX);
String startString;
long hits = 0;

void setup() {
  //Serial.begin(9600);

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);


  Bridge.begin();
  Console.begin();


  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  //server.listenOnLocalhost();
  server.noListenOnLocalhost();
  server.begin();

}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  client.println("hello");

  // There is a new client?
  if (client) {
    // read the command
    String command = client.readString();

    command.trim();        //kill whitespace

    client.println(command); // why does this return a full GET request instead of "on"?

    if (command == "on") {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);   
    }

    if (command == "off") {
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);              // wait for a second
    }


    // Close connection and free resources.
    client.stop();
    hits++;
  }

  delay(50); // Poll every 50ms
}
</code></pre>

<p>The response I get is (I have replaced my IP and port with X's):</p>

<blockquote>
  <p>hello</p>
  
  <p>GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX
  Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
  Accept:
  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,<em>/</em>;q=0.8
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36
  (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
  Accept-Encoding: gzip, deflate, sdch Accept-Language:
  en-GB,en-US;q=0.8,en;q=0.6</p>
</blockquote>

<p>I expected</p>

<blockquote>
  <p>hello </p>
  
  <p>on</p>
</blockquote>

<p>So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.</p>

<p>I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.</p>

<p>Then tried to restart the device and also a uhttpd restart i.e.:</p>

<pre class="lang-none prettyprint-override"><code>/etc/init.d/uhttpd restart
</code></pre>

<p>I have attempted to access the URL using my mobile phone (i.e. not on the same network).</p>

<p>Any ideas why my request is not being treated as HTTP?</p>
 7623: <p>It works!</p>

<p>The changes to the uhttpd must have done the trick to listen for http traffic on a given IP/port (other than 0.0.0.0:80).</p>

<p>Instead of supplying a port number for the server in the code, I would surmise that the change to the config takes care of it so this, so the port number in code is no longer needed:</p>

<p>YunServer server(XXXXX);</p>

<p>should be changed back to </p>

<p>YunServer server;</p>
