Http server embedded linux

Как развернуть Web Server на Linux Embedded

Я разрабатываю развернутый веб-интерфейс для устройства(как например на Frtz!Box) на Linux Embedded:

Где почитать по подробнее об этом. Опыт с Linux минимальный, т.к. от «кости мамонта».

Где почитать по подробнее об этом.

Доцент не выдал список литературы?

если опыт минимальный то врятли получится. apache2 надо установить.

Хотелось бы понять, с какой стороны начинать копать. Вообще-то Гуглем я пользоваться умею, только вот информации в сети я не нашел, либо очень старая с CGI и PHP. А доцент — это мой работодатель, который знает что хочет, но так-же как и я не знает как. Т.ч. обращаусь за помощью клуба.

Т.ч. — это что такое?

Где почитать по подробнее об этом.

Как эта страница может взаимодействовать с другими страницами, css-стилями и JS-скриптами, расположенными на устройстве (при отсутствии подключения к Интернету)?

если первая загруженная страница открывает соединение с WebSocket, как остальные страницы могут использовать это соединение?

Не страницы «открывают соединения», а браузер. С азов, получается, надо начинать.

Тебе не на форум нужно, а на курсы по вебне для самых маленьких.

Всем спасибо. Все свободны. Было очень приятно познакомиться.

по отдельности слова понятны, а вместе херня какая-то.

Как развернуть Web Server на Linux Embedded

собираешь сервер под архитектуру своего embedded, заливаешь на плату и настраиваешь запуск в что-у-тебя-там

Куча вопросов, которые джунам на собеседовании задают

какое это вообще имеет отношение к embedded?

мой работодатель, который знает что хочет, но так-же как и я не знает как

тут одно из двух: либо он пока не твой работодатель, либо он пока ещё твой работодатель

Обычно на форумы обращаются за помощью и для обмена опытом. Желающие помочь, помогают. Их к сожалению меньшенство. Фирмы, не делают все время одно и тоже, а иногда заглядывают в смежные области. Наша фирма не имела дело с Linux-ом и его Embedded частью, но я имею представление о том, как сделать Web приложение которое по WebSockret общается с железом. Также я имею представление, о том как это разместить на Cloud. В этом случае все, что нужно приложению, расположено в файловой системе Cloud и доступен Интернет. Мне нужно было от форума ответа на вопрос, как примерно тоже самое размесить на самом железе, чтобы это работало без интернета. К сожалению, желающих помочь реальными советами или направить к правильным источникам был только один vvn_black, за что ему и спасибо.

Используй просто nodejs, там и будет тебе и вебсервер и вебсокет сервер в одном флаконе. Не нужно все эти nginx, а тем более апачи собирать для таких простых задач как у тебя

Как получить первую HTML-страницу веб-интерфейса при доступе к устройству по его IP через браузер

Для этого на вашем устройстве должен быть запущен http-сервер. Какой именно — выбирать вам по имеющимся ресурсам на устройстве. Например, nginx, mongoose (civetweb), libmicrohttpd

Источник

hellerf/EmbeddableWebServer

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

EWS — Single .h File C Embeddable Web Server

Latest Version: 1.1.4 released September 9, 2021
Supported platforms: Linux, Mac OS X, Windows
License: BSD 2-clause

Embeddable Web Server is a web server in a single header file and has no external dependencies in the tradition of the STB libraries. It can serve static files and handle responses with C/C++ code (the server compiles in both). Here’s how to use it:

  1. #include «EmbeddableWebServer.h» (and #define EWS_HEADER_ONLY if you included it somewhere else)
  2. Call acceptConnectionsUntilStoppedFromEverywhereIPv4(NULL) , which will initialize a new server and block Note: If you want to take connections from a specific inteface/localhost you can use acceptConnectionsUntilStopped
  3. Fill out createResponseForRequest . Use the responseAlloc* functions to return a response or take over the connection yourself and return NULL. The easiest way to serve static files is responseAllocServeFileFromRequestPath. The easiest way to serve HTML is responseAllocHTML. The easiest way to serve JSON is responseAllocJSON. The server will free() your response once it’s been sent. When compiled with Objective-C, an autoreleasepool will be created for you.
  4. Use the connectionDebugStringCreate to aid in debugging.

See the EWSDemo.cpp file for more examples like chunked transfer, HTML forms, and JSON responses.

If you want to control server setup/teardown use serverInit , serverStop , and serverDeInit and pass that same Server in acceptConnectionsUntilStopped .

Источник

civetweb/civetweb

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

CivetWeb

The official home of CivetWeb is on GitHub https://github.com/civetweb/civetweb

Continuous integration for Linux and macOS (Travis CI):

Continuous integration for Windows (AppVeyor):

Test coverage check (coveralls, codecov) (using different tools/settings):

Читайте также:  Как заправить струйный принтер hp deskjet 2130

Static source code analysis (Coverity):

CodeQL semantic code analysis:

Project mission is to provide easy to use, powerful, C (C/C++) embeddable web server with optional CGI, SSL and Lua support. CivetWeb has a MIT license so you can innovate without restrictions.

CivetWeb can be used by developers as a library, to add web server functionality to an existing application.

It can also be used by end users as a stand-alone web server running on a Windows or Linux PC. It is available as single executable, no installation is required.

Where to find the official version?

End users can download CivetWeb binaries / releases from here on GitHub https://github.com/civetweb/civetweb/releases or SourceForge https://sourceforge.net/projects/civetweb/

Developers can contribute to CivetWeb via GitHub https://github.com/civetweb/civetweb

Due to a bug in Git for Windows V2.24 CivetWeb must be used with an earlier or later version (see also here).

Bugs and requests should be filed on GitHub https://github.com/civetweb/civetweb/issues

New releases are announced on Google Groups https://groups.google.com/d/forum/civetweb

Formerly some support question and discussion threads have been at Google groups. Recent questions and discussions use GitHub issues.

A very brief overview can be found on GitHub Pages https://civetweb.github.io/civetweb/

Quick start documentation

  • docs/Installing.md — Install Guide (for end users using pre-built binaries)
  • docs/UserManual.md — End User Guide
  • docs/Building.md — Building the Server (quick start guide)
  • docs/Embedding.md — Embedding (how to add HTTP support to an existing application)
  • docs/OpenSSL.md — Adding HTTPS (SSL/TLS) support using OpenSSL.
  • API documentation — Additional documentation on the civetweb application programming interface (civetweb.h).
  • RELEASE_NOTES.md — Release Notes
  • SECURITY.md — Security Policy
  • LICENSE.md — Copyright License

CivetWeb keeps the balance between functionality and simplicity by a carefully selected list of features:

  • Forked from Mongoose in 2013, before it changed the licence from MIT to commercial + GPL. A lot of enhancements have been added since then, see RELEASE_NOTES.md.
  • Maintains the liberal, permissive, commercial-friendly, MIT license
  • Project is free from copy-left licenses, like GPL, because you should innovate without restrictions.
  • Works on Windows, Mac, Linux, UNIX, IOS, Android, Buildroot, and many other platforms.
  • Scripting and database support (CGI, Lua Server Pages, Server side Lua scripts, Lua SQLite database, Server side JavaScript). This provides a ready to go, powerful web development platform in a one single-click executable with no dependencies. 0
  • Support for CGI, SSI, HTTP digest (MD5) authorization, WebSocket, WebDAV.
  • Experimental HTTP/2 support.
  • HTTPS (SSL/TLS) support using OpenSSL.
  • Optional support for authentication using client side X.509 certificates.
  • Resumed download, URL rewrite, file blacklist, IP-based ACL.
  • Can run as a Windows service or systemd service.
  • Download speed limit based on client subnet or URI pattern.
  • Simple and clean embedding API.
  • The source is in single file for drop in compilation.
  • Embedding examples included.
  • HTTP client capable of sending arbitrary HTTP/HTTPS requests.
  • Websocket client functionality available (WS/WSS).

Optionally included software

This project is very easy to install and use. Please read the documentation and have a look at the examples.

Recent questions and discussions usually use GitHub issues. Some old information may be found on the mailing list, but this information may be outdated.

Feel free to create a GitHub issue for bugs, feature requests, questions, suggestions or if you want to share tips and tricks. When creating an issues for a bug, add enough description to reproduce the issue — at least add CivetWeb version and operating system. Please see also the guidelines for Contributions and the Security Policy

Note: We do not take any liability or warranty for any linked contents. Visit these pages and try the community support suggestions at your own risk. Any link provided in this project (including source and documentation) is provided in the hope that this information will be helpful. However, we cannot accept any responsibility for any content on an external page.

Contributions are welcome provided all contributions carry the MIT license.

DO NOT APPLY fixes copied from Mongoose to this project to prevent GPL tainting. Since 2013, CivetWeb and Mongoose have been developed independently. By now the code base differs, so patches cannot be safely transferred in either direction.

Some guidelines can be found in docs/Contribution.md.

CivetWeb was forked from the last MIT version of Mongoose in August 2013. Since then, CivetWeb has seen many improvements from various authors (Copyright (c) 2013-2021 the CivetWeb developers, MIT license).

A list of authors can be found in CREDITS.md.

CivetWeb is based on the Mongoose project. The original author of Mongoose was Sergey Lyubka(2004-2013) who released it under the MIT license. However, on August 16, 2013, Mongoose was relicensed to a dual GPL V2 + commercial license and CiwetWeb was created by Thomas Davis (sunsetbrew) as «the MIT fork of mongoose». The license change and CivetWeb fork was mentioned on the Mongoose Wikipedia page as well, but it’s getting deleted (and added again) there every now and then.

Using the CivetWeb project ensures the MIT licenses terms are applied and GPL cannot be imposed on any of this code, as long as it is sourced from here. This code will remain free with the MIT license protection.

Источник

RealTimeLogic/MinnowServer

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Minnow Server, a super small and fast embedded HTTP(S) WebSocket server, lets small microcontrollers with no external memory act as real-time web servers.

The Minnow Server includes porting layers for the following platforms:

  • FreeRTOS-TCP https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/
  • Harmony — Microchip Harmony TCP/IP
  • MDK — Keil MDK
  • MQX — MQX and RTCS from Freescale
  • NetX — ThreadX and NetX from Express Logic (Azure RTOS)
  • BSD Sockets — POSIX including Linux, Mac, VxWorks, QNX, and Zephyr
  • INTEGRITY — Green Hills Software
  • Windows — Standard Windows and Win CE
  • lwIP — lwIP Netconn API for RTOS enabled systems
Читайте также:  Заправка принтеров brother dcp 7057r

Bare metal (no RTOS) event based porting layers:

The above mentioned porting layers are not included with the Minnow Server. Carefully read the instructions below to find out how to download the porting layers. Using ESP8266 or ESP32? Check out the ESP8266 build files and the SharkSSL ESP32 IDE.

Minnow Server: One Of Three WebSocket Servers

The Minnow Server is one of three WebSocket server implementations provided by Real Time Logic.

  • The Minnow Server is designed for resource constrained devices such as a Cortex-M0 and ESP8266. A Minnow Server application must be designed as an SPA and preferably use the SPA amalgamator service for converting the SPA assets into a C array. The SharkSSL ESP8266 IDE and the SharkSSL ESP32 IDE include a ready to compile and run Minnow Server example.
  • The Barracuda Web Server’s WebSocket Server enables hybrid server-side/client-side web applications to communicate using both HTTP(S) and (secure) WebSockets. The SharkSSL ESP32 IDE includes a ready to compile and run Barracuda Web Server WebSocket example. Consider using this WebSocket server if you plan on using HTTP(S) services in addition to WS(S) services and/or require a dual WSS/WS server.
  • The Barracuda App Server’s WebSocket Server provides the easiest to use solution, in which server side business logic can be designed in the easy to learn Lua scripting language. With the Barracuda App Server, much of the device’s high level logic can be implemented in Lua. Just as Lua is popular with rapid game development, now embedded systems can benefit from the same. The SharkSSL ESP32 IDE includes a ready to compile and run Barracuda App Server project called the LSP Application Manager, which can be used as the foundation for your development. See the online tutorial for an interactive WebSocket example.

Minnow Server SPA Reference Example

This repository includes the Minnow Server and the Minnow Server Single Page Application (SPA) Reference Example. The Minnow Server is also included in the SharkSSL Repository and will use a secure (HTTPS) connection when used with SharkSSL, but note that the SharkSSL repository does not include the SPA Reference Example. Check out the SharkSSL IDE if you want to easily test the Minnow Server Reference Example in secure mode (HTTPS). See the tutorial Beginner’s Guide To Secure IoT Communication and X.509 Certificate Managment for details.

The Minnow Server Reference Example is a fully functional example that follows the design guidelines outlined in the tutorial Creating Single-Page Apps with the Minnow Server. The following Figure 1 shows the HTML5 LED web page provided by this example. The example is designed such that one can use it as a base for designing a professional web based device management application.

Figure 1: The Single Page HTML5 Based Web Application

The example provides a direct WebSocket server API designed for local Intranet use and an optional IoT connection that enables the WebSocket server running on a private network and protected by a firewall to also be accessible from the Internet. The following figure shows how a local user and how an external user can access the same device.

Figure 2: Access reference example locally or via the Internet

The optional IoT solution enables a device installed on a private network to be accessed from the Internet without having to do any network configurations. The example includes the source code for the online IoT server setup. The online server can easily be installed on any cloud solution, including low cost Virtual Private Servers. An interesting feature of the IoT version is that it allows the external user to use a secure TLS connection when the Minnow Server is not TLS enabled.

Compiling the Reference Example

The Minnow Server and the reference example can be compiled for any microcontroller. The Minnow Server includes porting layers for many RTOS’s and TCP/IP stacks. However, a few code sections in the example code are designed to run on a non RTOS environment and must be modified if you plan on compiling the example «as is» for a microcontroller. The purpose with the reference example is educational, and compiling and running the code on a host computer is the first step. You may compile the code on Windows using the included Visual C++ project file or on Linux/Mac using the included makefile.

In addition to the host build environments, we provide a ready to use build environment for FreeRTOS/lwIP ESP8266. The following video shows how to compile and upload the code to the ESP8266. The video also shows how to IoT enable the Minnow Server example. See the embedded.com article How to install a secure embedded Web server on ESP8266 for detailed instructions.

  1. Carefully read the Minnow Server SPA tutorial, which provides details on the complete SPA development process.
  2. Perform the following commands on the command line to clone the Minnow Server and the required libraries:

The JSON and SMQ libraries are used by the Minnow Server reference example. The SMQ stack is needed even if you do not plan on IoT enabling the reference example since the Minnow Server uses the SMQ TCP/IP porting layer.

Note: If you are not planning on IoT enabling the Minnow Server, copy the SMQ/src/arch/ directory to the Minnow Server.

Compile and run for developer mode

Compile the code and start the server. The server will attempt to use the default HTTP port or an alternative port if it cannot open the default port. Run the following command on Linux to open the default port 80: sudo ./minnow

Читайте также:  Windows ssh client что это

Open your hosts file and add the following entry:

Drag and drop the main HTML file www/index.html into your browser window. The JavaScript code that is part of the SPA will connect to ws://device. Note that the code assumes the server listens on the default port 80. Make sure the server listens on the default port or edit the JavaScript code and add the port number to the URL.

Login by using the username ‘root’ and password ‘password’.

Compile and run for release mode

Follow the Minnow Server design guide for how to amalgamate and compress all web resources in the ‘www’ directory. Make sure to select Gzip compression so the online service creates the required index.c file. Replace example/index.c with the generated file.

Compile and run the server. You may now load the web interface directly from the server by navigating to http://device.

Running on a host operating system in a command window

When running the server in a command window, the four LEDs can also be controlled from the command line by using the keyboard keys ‘b’ to ‘e’. A lowercase letter turns the LED off and an uppercase letter turns the LED on.

The temperature can be controlled from the command line by pressing the up or down arrow keys.

How to IoT enable the reference example

The Minnow Server reference example can also be accessed from outside the Intranet when the reference example is IoT enabled and an SMQ broker is deployed on the Internet. You do not need to setup an online server if you simply want to test the IoT connectivity. In the following example, we will show how to IoT enable the reference example and have the reference example connect to an SMQ broker running on another computer on your Intranet. The SMQ broker needs another IP address than the one used for the Minnow Server. You can either use another computer on your Intranet or run the SMQ broker in a virtual machine (VM).

Copy the «IoT» directory to the computer (or VM) where the SMQ broker will run. Download the Mako Server and unpack the server on the same computer. You need the mako executable and mako.zip. Copy those two files to the IoT directory. You should have mako (Win: mako.exe), mako.zip, and the directory www in the IoT directory. The ‘www’ directory contains the server side app that sets up the SMQ broker. You also need a copy of the Minnow Server application in the IoT/www directory. Copy everything from ‘www’ (the Minnow Server application) to IoT/www and rename IoT/www/index.html to IoT/www/device.htmls.

Open device.htmls (The SPA index.html copy) in an editor and add the following line, just below the list of included JavaScript files:

Start the Mako Server as follows:

mako -l::www (on Linux: ./mako -l::www)

The Mako Server prints the port numbers used in the console. We recommend making sure the Mako Server uses the default HTTP port 80. If not, you will have to change the URL in the Minnow Server reference example by opening example/main.c and by changing the SMQ_URL. Change the URL to the following, where portno is the port number the Mako Server is listening on.

#define SMQ_URL SMQ_PROTOCOL SMQ_DOMAIN » :portno/minnow-smq.lsp?device=»

Open your hosts file and add the following entry:

Where IP-ADDR is the IP address of the computer or VM running the Mako Server.

Alternatively, open example/main.c and search for SMQ_DOMAIN. Change the domain «MakoServer » to the IP address of the computer running the Mako Server.

Open example/main.c and add the following at the top of the file, just below the initial comment:

Compile and run the reference example.

Use a browser and navigate to http://MakoServer. The main page shows a list of connected devices. You should see the one device and you may click the link to manage the device via the SMQ broker.

Installing the SMQ Broker on an Online VPS or Cloud Server

Follow the Setting up an Online SMQ IoT Broker tutorial. Replace the server side app in this tutorial with the content of IoT/www.

  • src/MSLib.c — the Minnow Server C source code library.
  • src/MSLib.h — the Minnow Server library header file.
  • example/src/main.c — the Minnow Server reference example code.
  • example/ JsonStaticAlloc.c — shows how to use JSON with static allocators.
  • example/ index.c — the amalgamated and compressed Single Page App (SPA web page).

Single Page Application (SPA)

  • www/index.html — the SPA framework.
  • www/css — All CSS3 files.
  • www/js/connection.js — manages the WebSocket or SMQ connection and provides a high level API for JSON message handling (sets global object ‘ws’). The implementation is generic and can be reused for other projects.
  • www/js/interactions.js — The SPA interaction contains the JavaScript UI management and uses connection.js for server interaction.
  • www/js/LED.js — code for dynamically creating LED HTML UI (sets global object ‘led’)
  • www/plugins/ — third party resources used by the SPA

IoT Server Side Code (Mako Server App)

  • IoT/www/.preload — The application’s startup script sets up the SMQ broker and server app.
  • IoT/www/smq.lsp — converts HTTP(S) connections to SMQ connections. The URL domain/smq.lsp is used by both device code and JavaScript code for setting up a persistent SMQ connection.
  • index.lsp — Looks up device by ID and forwards the request to device.htmls if device is found. The file device.htmls is a copy of the SPA main index.html file.

Embedded Web Server Considerations

Consider reading the following tutorials as they may save you from serious problems down the road:

About

A super small and fast embedded HTTP(S) WebSocket server

Источник

Поделиться с друзьями
КомпСовет
Adblock
detector