2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PepperやNao内にHTMLを配置して外部からアクセスする方法

Posted at

PepperやNaoには標準でWebサーバ(nginx)が組み込まれており、ビヘイビア内にコンテンツ(HTML等)を配置してブラウザ等でアクセス可能となっている。
(ちなみに、Pepperのタブレットに表示するコンテンツ(HTML等)はこの仕組みを使用)

但し、その他の仮想ディレクトリ(ビヘイビア内以外)に設定されている物理ディレクトリへのアクセスはroot権限が必要なため、事実上使用できないものと考えた方が良いと思われる。
(Pepperだけは何故かアクセス可能なディレクトリが用意されているようなので後述する)

外部からのアクセス方法

HTMLを入れたビヘイビアをPepper(NAO)にインストールした後、以下のURLをPC等のブラウザでアクセスする

http://<pepepr or nao ip>/apps/<アプリケーションID>/<htmlファイル名>
※ビヘイビア内の"html"はパスに含まれません

(おまけ)PepperとNAOのnginxの設定ファイルの違いについて

PepperとNAOのnginx.confの設定ファイルを確認したところPepperだけが「/ota_files/」という仮想ディレクトリに「/home/nao/.local/share/ota」が設定されており、root権限が無くてもアクセス可能となっていた(※動作確認済み)。
アプリで出力したコンテンツを配置したりする場合等に使えるかもしれません。

Pepperの/etc/nginx/ngix.conf抜粋
        location / {
            root /opt/aldebaran/var/www/robotsgate;
        }
        location ^~ /advanced {
            alias /opt/aldebaran/var/www/apps/robots_advanced/html;
        }
        location ^~ /licenses {
            alias /opt/aldebaran/var/www/licenses;
        }
        location /libs {
            root /opt/aldebaran/var/www;
        }
        location ~* /libs/qimessaging/.*/qimessaging.js {
            auth_pam              "Secure Zone";
            auth_pam_service_name "nginx";
        }
        location ~* /libs/qimessaging/.*/socket.io/ {
            rewrite /libs/qimessaging/(.*)/socket.io/(.*) /$1/$2 break;
            proxy_pass http://127.0.0.1:8002;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
        }
        location ~ /apps/.*/html/?.* {
            root /opt/aldebaran/var/www;
        }
        location ^~ /apps {
            rewrite ^(/apps/[a-zA-Z0-9_\.-]*)(/.*)$ /$1/html$2 break;
        }
        location /ota_files/ {
          alias /home/nao/.local/share/ota/;
        }
        location /version {
          root /opt/aldebaran/etc;
        }
Naoの/etc/nginx/ngix.conf抜粋
        location / {
            root /var/www/robotsgate;
        }
        location ^~ /advanced {
            alias /var/www/oldrobotwebpage;
        }
        location /libs {
            root /var/www;
        }
        location ^~ /libs/qimessaging/1.0/qimessaging.js {
            auth_pam              "Secure Zone";
            auth_pam_service_name "nginx";
        }
        location ^~ /libs/qimessaging/1.0/socket.io/ {
            rewrite /libs/qimessaging/1.0/socket.io/(.*) /socket.io/$1 break;
            proxy_pass http://127.0.0.1:8002;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
        }
        location ~ /apps/.*/html/?.* {
            root /var/www;
        }
        location ^~ /apps {
            rewrite ^(/apps/[a-zA-Z0-9_\.-]*)(/.*)$ /$1/html$2 break;
        }
        location ^~ /services {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/fcgi-nao.sock;
            fastcgi_param SCRIPT_NAME /django-fcgi;
        }

以上

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?