My wife gave me a Yun for Christmas and 1 have started to play around with the web server. One of the first things I thought I might do, is hide the web control panel on a custom port. So I added a config section to /etc/config/uhttpd
#/etc/config/uhttpd
# User Server configuration
config uhttpd main
list listen_http 0.0.0.0:80
list listen_https 0.0.0.0:443
option home /wwwusr
option index_page index.html
option rfc1918_filter 0
option max_requests 10
option cert /etc/uhttp.crt
option key /etc/uhttpd.key
option cgi_prefix /cgi-bin
list interpreter ".php=/usr/bin/php-cgi"
list interpreter ".cgi=/usr/bin/perl"
option script_timeout 60
option network_timeout 30
option tcp_keepalive 1
option config /etc/httpd.conf
# Admin Server configuration
config uhttpd admin
list listen_http 0.0.0.0:8099
list listen_https 0.0.0.0:8443
option home /www
option rfc1918_filter 0
option max_requests 2
option cert /etc/uhttpd.crt
option key /etc/uhttpd.key
option cgi_prefix /cgi-bin
option script_timeout 60
option network_timeout 30
option tcp_keepalive 1
option realm OpenWrt
option config /etc/httpd.conf
Where I am stuck is trying to get the bridge interface working with the website located in the /wwwusr folder
I have uploaded this sketch
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
YunServer server;
String startString;
long hits = 0;
uint8_t pin13State = HIGH;
void setup() {
Serial.begin(9600);
Serial.println("Setup...");
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
server.listenOnLocalhost();
server.begin();
}
void loop() {
uint8_t lastHits = hits;
// put your main code here, to run repeatedly:
YunClient client = server.accept();
if (client) {
String command = client.readString();
command.trim();
Serial.println(command);
client.stop();
hits++;
}
//flash the LED
pinMode(13, INPUT);
pin13State == digitalRead(13);
if (pin13State == HIGH) {
pin13State = LOW;
}
else {
pin13State = HIGH;
}
pinMode(13, OUTPUT);
digitalWrite(13, pin13State);
//print UTRL hits
if (lastHits != hits) {
Serial.print("hits=");
Serial.println(hits);
}
delay(1000);
}
[quote author=Federico Fissore link=topic=206899.msg1523071#msg1523071 date=1388231226]
Can you confirm that http://yun.local:8099/arduino/helloworld is printing helloworld in the serial monitor?[/quote]
I am 99.9% sure. I flashed back to a default image so I can not retest, I am afraid.
the webpanel control panel and the /arduino/ endpoint are the same application code, so I guess you can't do that easily
Am I right in assuming the response is passed to the luci binary in /www/cgi-bin and that binary depends on the contents of /www/luci-static? Is there any other process in the chain? Sorry to press but I would like to get my head around how the response data is passed around and in what order it happens.
you have to modify file /etc/httpd.conf, that defines two url aliases.
Thanks. Your pointer helped me on my way.
I have managed to get almost what I want now.
//root@yun1:~# cat /etc/httpd.conf
A:/arduino:/cgi-bin/luci/arduino%s
A:/mydata:/cgi-bin/luci/arduino%s
//hide the arduino web control panel
mv /www/index.html /www/admin.html
ln -s /www/sd/www/js1.html index.html
Ultimately I would like to make the web control panel completely inaccessible to the internet but this is good enough for now.
MattS-UK:
Am I right in assuming the response is passed to the luci binary in /www/cgi-bin and that binary depends on the contents of /www/luci-static? Is there any other process in the chain? Sorry to press but I would like to get my head around how the response data is passed around and in what order it happens.
If with "depends" you mean that the generated html pages (from cgi-bin) load images and javascripts from luci-static, then yes.
MattS-UK:
Ultimately I would like to make the web control panel completely inaccessible to the internet but this is good enough for now.
You can use a strong password: webpanel will still be accessible, but unusable
By "depends" I mean, will the luci binary still pass data, sent in the HTTP request, to the bridge, if the static-content folder is removed. I guess I could test this myself.
Maybe it would be better to tell you the problem I am trying to solve. I want to pass data sent to uhttpd in a URL, to my sketch, without having to learn yet another programming language (lua, perl, python).
You can use a strong password: webpanel will still be accessible, but unusable
Not the answer I was looking for but many thanks for your assistance anyway.
MattS-UK:
Maybe it would be better to tell you the problem I am trying to solve. I want to pass data sent to uhttpd in a URL, to my sketch, without having to learn yet another programming language (lua, perl, python).
Use the Bridge library then. Take a look at the TemperatureWebPanel example: it shows how you can talk to your sketch via URLs. There is a blog post about it: in essence, you can send commands to your sketch. In the example, with the URL "http://blabla/arduino/temperature", the command "temperature" is sent to the sketch and instructs it to read and report the temp sensor value