### Start and Enable Angie PRO Service on openSUSE Source: https://cn.angie.software/angie/docs/installation/pro_packages Starts the Angie PRO service using 'systemctl start angie' and configures it to start automatically on system boot using 'systemctl enable angie'. ```bash $ sudo systemctl start angie $ sudo systemctl enable angie ``` -------------------------------- ### Start Angie Service on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Starts the Angie web server service. This command is used to initiate the Angie PRO process after installation or if it has been stopped. ```bash $ sudo systemctl start angie ``` -------------------------------- ### Start and Enable Angie PRO Service on FreeBSD Source: https://cn.angie.software/angie/docs/installation/pro_packages Starts the Angie PRO service and configures it to start automatically on system reboot using 'service angie start' and 'sysrc angie_enable=YES'. ```bash $ sudo service angie start $ sudo sysrc angie_enable=YES ``` -------------------------------- ### Start and Enable Angie Service on RHEL-based systems Source: https://cn.angie.software/angie/docs/installation/pro_packages These commands are used to start the Angie service and configure it to automatically start on system boot. `systemctl start angie` starts the service immediately, while `systemctl enable angie` ensures it runs after reboots. ```bash $ sudo systemctl start angie $ #                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ­                                                                                                           ``` -------------------------------- ### Enable Angie Service on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Configures the Angie service to start automatically on server boot. This ensures that the web server is available whenever the system restarts. ```bash $ sudo systemctl enable angie ``` -------------------------------- ### Install Angie on openSUSE Source: https://cn.angie.software/angie/docs/installation/oss_packages Installs the Angie web server on openSUSE. This procedure requires creating a .repo file to add the Angie repository, refreshing the Zypper index, and then installing the 'angie' package. It also includes commands to start and enable the Angie service using systemctl. ```bash [angie] name=Angie repo baseurl=https://download.angie.software/angie/opensuse/$releasever_major/ gpgcheck=1 enabled=1 gpgkey=https://angie.software/keys/angie-signing.gpg.asc $ sudo zypper refresh $ sudo zypper install -y angie $ sudo systemctl start angie $ sudo systemctl enable angie ``` -------------------------------- ### Install and Manage Angie on RHEL-based Systems Source: https://cn.angie.software/angie/docs/installation/oss_packages This set of commands covers installing the Angie package using either `yum` or `dnf`, installing additional packages, starting the Angie service, and enabling it to start automatically on system boot. These commands are applicable to distributions like AlmaLinux, CentOS, Rocky Linux, and Oracle Linux. ```bash $ sudo yum install -y angie $ # -- OR -- $ sudo dnf install -y angie ``` ```bash $ sudo yum install -y $ # -- OR -- $ sudo dnf install -y ``` ```bash $ sudo systemctl start angie ``` ```bash $ sudo systemctl enable angie ``` -------------------------------- ### Install Angie on FreeBSD Source: https://cn.angie.software/angie/docs/installation/oss_packages Installs the Angie web server on FreeBSD. This involves creating directories for repository configuration, defining the repository in a .conf file, downloading the GPG key, updating package indexes, and installing the 'angie' package. Includes commands to start and enable the service. ```bash $ sudo mkdir -p /usr/local/etc/pkg/angie/ /usr/local/etc/pkg/repos/ $ echo "angie: { url: \"https://download.angie.software/angie/freebsd/${VERSION_MAJOR}/${ARCH}\", signature_type: \"pubkey\", pubkey: \"/usr/local/etc/pkg/angie/angie-signing.rsa\", enabled: yes }" | sudo tee /usr/local/etc/pkg/repos/angie.conf $ sudo curl -o /usr/local/etc/pkg/angie/angie-signing.rsa \ https://angie.software/keys/angie-signing.rsa $ sudo pkg update $ sudo pkg install -y angie $ sudo service angie start $ sudo sysrc angie_enable=YES ``` -------------------------------- ### Install Additional Packages on RHEL-based systems Source: https://cn.angie.software/angie/docs/installation/pro_packages This command allows for the installation of any additional required packages using `yum` or `dnf`. Replace `<软件包名称>` with the actual name of the package you wish to install. ```bash $ sudo yum install -y <软件包名称> $ # --         -- $ sudo dnf install -y <软件包名称> ``` -------------------------------- ### Install Prerequisites for Angie PRO on OSNova Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs essential packages for adding the Angie PRO repository on OSNova. This includes 'ca-certificates' and 'curl'. ```bash $ sudo apt-get update $ sudo apt-get install -y ca-certificates curl ``` -------------------------------- ### Angie Configuration Examples for Redis2 Module Source: https://cn.angie.software/angie/docs/installation/external-modules/redis2 This provides several Nginx configuration examples demonstrating how to use the Redis2 module for various operations. It includes setting and getting keys, handling query parameters, and executing multiple pipelined commands. ```nginx upstream redis_upstream { server 127.0.0.1:6379; } server { listen 80; server_name localhost; # 设置键值 location /foo { set $value 'first'; redis2_query set one $value; redis2_pass redis_upstream; } # 通过键获取值 location /bar { redis2_query get one; redis2_pass redis_upstream; } # 从查询参数设置键值 location /set { set_unescape_uri $key $arg_key; set_unescape_uri $val $arg_val; redis2_query set $key $val; redis2_pass 127.0.0.1:6379; } # 从查询参数通过键获取值 location /get { set_unescape_uri $key $arg_key; redis2_query get $key; redis2_pass 127.0.0.1:6379; } # 执行多个管道命令 location /pipeline { set $value 'first'; redis2_query set one $value; redis2_query get one; redis2_query set one 'first first'; redis2_query get one; redis2_pass 127.0.0.1:6379; } # 执行在查询参数中传递的任意命令 location /cmd { set_unescape_uri $cmd $arg_command; redis2_raw_query "$cmd\r\n"; redis2_pass 127.0.0.1:6379; } } ``` -------------------------------- ### Refresh Repository Index and Install Angie PRO on openSUSE Source: https://cn.angie.software/angie/docs/installation/pro_packages Refreshes the Zypper package manager's repository index to include the Angie PRO repository and then installs the 'angie-pro' package. An optional step for installing additional packages is also provided. ```bash $ sudo zypper refresh $ sudo zypper install -y angie-pro $ sudo zypper install -y ``` -------------------------------- ### Configure Angie PRO Repository on FreeBSD Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates the '/usr/local/etc/pkg/repos/angie.conf' file to define the Angie PRO repository. This configuration specifies the repository URL, signature type, public key path, and enables the repository. ```text angie: { url: "https://download.angie.software/angie-pro/freebsd/${VERSION_MAJOR}/${ARCH}", signature_type: "pubkey", pubkey: "/usr/local/etc/pkg/angie/angie-signing.rsa", enabled: yes } ``` -------------------------------- ### Create Directories for Angie PRO Repository on FreeBSD Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates the necessary directories for configuring the Angie PRO package repository on FreeBSD. These include '/usr/local/etc/pkg/angie/' and '/usr/local/etc/pkg/repos/'. ```bash $ sudo mkdir -p /usr/local/etc/pkg/angie/ /usr/local/etc/pkg/repos/ ``` -------------------------------- ### Install APT Transport Helpers on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs necessary packages for APT to handle HTTPS repositories and retrieve distribution information. These are prerequisites for adding external repositories. ```bash $ sudo apt-get update $ sudo apt-get install -y apt-transport-https \ ca-certificates curl gnupg2 ``` -------------------------------- ### Install Angie on Alt Linux Source: https://cn.angie.software/angie/docs/installation/oss_packages This guide outlines the installation of Angie on Alt Linux. It involves creating a directory for SSL keys, installing prerequisites such as `curl` and `apt-https`, downloading and importing the Angie GPG key, configuring the repository list for different Alt Linux versions, updating the package index, installing the Angie package, and managing the service. ```bash $ sudo mkdir -p /etc/ssl/angie/ ``` ```bash $ sudo apt-get update $ sudo apt-get install -y curl apt-https ``` ```bash $ sudo curl -o /etc/ssl/angie/angie-signing.gpg \ https://angie.software/keys/angie-signing.gpg ``` ```bash $ sudo gpg --no-default-keyring \ --keyring /usr/lib/alt-gpgkeys/pubring.gpg --import /etc/ssl/angie/angie-signing.gpg ``` ```bash $ echo 'simple-key "angie" { Fingerprint "EB8EAF3D4EF1B1ECF34865A2617AB978CB849A76"; Name "Angie (Signing Key) "; }' | sudo tee /etc/apt/vendors.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie] https://download.angie.software/angie/altlinux/11/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie] https://download.angie.software/angie/altlinux/10/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie] https://download.angie.software/angie/altlinux-sp/10/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie] https://download.angie.software/angie/altlinux-sp/8/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ sudo apt-get update ``` ```bash $ sudo apt-get install -y angie ``` ```bash $ sudo apt-get install -y ``` ```bash $ sudo systemctl start angie ``` ```bash $ sudo systemctl enable angie ``` -------------------------------- ### Install Angie PRO Package on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs the Angie PRO web server package using APT. The '-y' flag automatically confirms any prompts during the installation process. ```bash $ sudo apt-get install -y angie-pro ``` -------------------------------- ### Create SSL Directory for Angie Source: https://cn.angie.software/angie/docs/installation/pro_packages This command creates a directory for SSL certificates and keys required for the Angie repository. It uses `sudo` for administrative privileges and `-p` to create parent directories if they don't exist. ```bash $ sudo mkdir -p /etc/ssl/angie/ ``` -------------------------------- ### Configure Angie PRO Repository on openSUSE Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates the '/etc/zypp/repos.d/angie.repo' file to configure the Angie PRO repository on openSUSE. It specifies the repository URL, enabling automatic refresh, GPG key verification, and uses the SSL certificate bundle. ```text [angie-pro] enabled=1 autorefresh=1 baseurl=https://download.angie.software/angie-pro/opensuse/$releasever_major?ssl_clientcert=/etc/ssl/angie/angie-repo-bundle.crt&ssl_verify=peer gpgcheck=1 gpgkey=https://angie.software/keys/angie-signing.gpg.asc ``` -------------------------------- ### Install Additional Packages on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs any other required or desired packages alongside Angie PRO. Replace '' with the actual name of the package you wish to install. ```bash $ sudo apt-get install -y ``` -------------------------------- ### Configure Repository Access for Angie PRO on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates a configuration file to enable secure access to the Angie PRO repository using SSL certificates and keys. This file specifies the paths to the certificate, private key, and enables peer and host verification. ```text Acquire::https::download.angie.software::Verify-Peer "true"; Acquire::https::download.angie.software::Verify-Host "true"; Acquire::https::download.angie.software::SslCert "/etc/ssl/angie/angie-repo.crt"; Acquire::https::download.angie.software::SslKey "/etc/ssl/angie/angie-repo.key"; ``` -------------------------------- ### Update Package Index and Install Angie PRO on FreeBSD Source: https://cn.angie.software/angie/docs/installation/pro_packages Updates the package repository index on FreeBSD using 'pkg update' and then installs the 'angie-pro' package. An optional step for installing additional packages is also included. ```bash $ sudo pkg update $ sudo pkg install -y angie-pro $ sudo pkg install -y ``` -------------------------------- ### Install Prerequisites for Angie PRO on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs essential packages required to add the Angie PRO repository on Debian and Ubuntu. These include 'apt-transport-https', 'lsb-release', 'ca-certificates', 'curl', and 'gnupg2'. ```bash $ sudo apt-get update $ sudo apt-get install -y apt-transport-https lsb-release \ ca-certificates curl gnupg2 ``` -------------------------------- ### Create Angie PRO SSL Certificate Bundle on openSUSE Source: https://cn.angie.software/angie/docs/installation/pro_packages Combines the Angie PRO repository certificate ('angie-repo.crt') and private key ('angie-repo.key') into a single bundle file '/etc/ssl/angie/angie-repo-bundle.crt'. This bundle is used for repository access. ```bash $ cat /etc/ssl/angie/angie-repo.crt /etc/ssl/angie/angie-repo.key | \ sudo tee -a /etc/ssl/angie/angie-repo-bundle.crt > /dev/null ``` -------------------------------- ### Configure Angie PRO APT Repository Settings on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates a configuration file for APT to specify SSL verification settings and certificate paths for the Angie PRO repository. This ensures secure connections to the download server. ```bash Acquire::https::download.angie.software::Verify-Peer "true"; Acquire::https::download.angie.software::Verify-Host "true"; Acquire::https::download.angie.software::SslCert "/etc/ssl/angie/angie-repo.crt"; Acquire::https::download.angie.software::SslKey "/etc/ssl/angie/angie-repo.key"; ``` -------------------------------- ### Configure Angie PRO APT Transport Settings on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates an APT configuration file to specify SSL certificate and key paths for the Angie PRO repository. This ensures secure communication when downloading packages. ```bash $ ( echo 'Acquire::https::Verify-Peer "true";'; echo 'Acquire::https::Verify-Host "true";'; echo 'Acquire::https::SslCert "/etc/ssl/angie/angie-repo.crt";'; echo 'Acquire::https::SslKey "/etc/ssl/angie/angie-repo.key";'; ) | sudo tee -a /etc/apt/apt.conf >/dev/null ``` -------------------------------- ### Create SSL Directory for Angie PRO on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Creates the necessary directory for SSL certificates and keys required for the Angie PRO repository on Debian and Ubuntu systems. This is a prerequisite for secure repository access. ```bash $ sudo mkdir -p /etc/ssl/angie/ ``` -------------------------------- ### Add Angie PRO Repository for Alt Linux Versions Source: https://cn.angie.software/angie/docs/installation/pro_packages Adds the Angie PRO repository to the APT sources list for different Alt Linux versions (11, 10, SP 10, SP 8). This allows the system to find and install Angie PRO packages. ```bash $ echo "rpm [angie-pro] https://download.angie.software/angie-pro/altlinux/11/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie-pro] https://download.angie.software/angie-pro/altlinux/10/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie-pro] https://download.angie.software/angie-pro/altlinux-sp/10/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` ```bash $ echo "rpm [angie-pro] https://download.angie.software/angie-pro/altlinux-sp/8/ $(uname -m) main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` -------------------------------- ### Add Angie PRO Repository for Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Adds the Angie PRO repository to the APT sources list for Astra SE. It dynamically determines the Astra SE version and appends the correct repository URL. ```bash $ echo "deb https://download.angie.software/angie-pro/astra-se/$(egrep -o \ '[0-9]+\\.[0-9]+' /etc/astra_version) unstable main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ``` -------------------------------- ### Download Angie PRO Public Key for Package Verification on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Downloads the public signing key for the Angie PRO repository to '/etc/apt/trusted.gpg.d/angie-signing.gpg'. This allows the system to verify the authenticity of downloaded packages. ```bash $ sudo curl -o /etc/apt/trusted.gpg.d/angie-signing.gpg \ https://angie.software/keys/angie-signing.gpg ``` -------------------------------- ### Download and Import Angie PRO GPG Key on Alt Linux Source: https://cn.angie.software/angie/docs/installation/pro_packages Downloads the Angie PRO repository's public GPG key and imports it into the APT keyring for package verification. This ensures the integrity of packages downloaded from the Angie repository. ```bash $ curl -o ~/angie-signing.gpg https://angie.software/keys/angie-signing.gpg && \ sudo gpg --no-default-keyring --keyring /usr/lib/alt-gpgkeys/pubring.gpg --import ~/angie-signing.gpg ``` -------------------------------- ### Install Angie PRO Package on RHEL-based systems Source: https://cn.angie.software/angie/docs/installation/pro_packages These commands install the Angie PRO package using either `yum` or `dnf` package managers. The `-y` flag automatically confirms any prompts during the installation process. ```bash $ sudo yum install -y angie-pro $ # --         -- $ sudo dnf install -y angie-pro ``` -------------------------------- ### Update Package Index and Install Angie PRO on OSNova Source: https://cn.angie.software/angie/docs/installation/pro_packages Updates the package index on OSNova to include packages from the Angie PRO repository and installs the 'angie' package. An optional step for installing extra packages is also provided. ```bash $ sudo apt-get update $ sudo apt-get install -y angie $ sudo apt-get install -y ``` -------------------------------- ### Simple 'ngx_foo_module' Implementation (C) Source: https://cn.angie.software/angie/docs/development An example of a basic Angie module named 'ngx_foo_module'. It demonstrates defining configuration, commands, context, and lifecycle functions for enabling the module. ```c /* * Copyright (C) Author. */ #include #include typedef struct { ngx_flag_t enable; } ngx_foo_conf_t; static void *ngx_foo_create_conf(ngx_cycle_t *cycle); static char *ngx_foo_init_conf(ngx_cycle_t *cycle, void *conf); static char *ngx_foo_enable(ngx_conf_t *cf, void *post, void *data); static ngx_conf_post_t ngx_foo_enable_post = { ngx_foo_enable }; static ngx_command_t ngx_foo_commands[] = { { ngx_string("foo_enabled"), NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, 0, offsetof(ngx_foo_conf_t, enable), &ngx_foo_enable_post }, ngx_null_command }; static ngx_core_module_t ngx_foo_module_ctx = { ngx_string("foo"), ngx_foo_create_conf, ngx_foo_init_conf }; ngx_module_t ngx_foo_module = { NGX_MODULE_V1, &ngx_foo_module_ctx, /* module context */ ngx_foo_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING }; static void * sngx_foo_create_conf(ngx_cycle_t *cycle) { ngx_foo_conf_t *fcf; fcf = ngx_pcalloc(cycle->pool, sizeof(ngx_foo_conf_t)); if (fcf == NULL) { return NULL; } fcf->enable = NGX_CONF_UNSET; return fcf; } static char * sngx_foo_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_foo_conf_t *fcf = conf; ngx_conf_init_value(fcf->enable, 0); return NGX_CONF_OK; } static char * sngx_foo_enable(ngx_conf_t *cf, void *post, void *data) { ngx_flag_t *fp = data; if (*fp == 0) { return NGX_CONF_OK; } ngx_log_error(NGX_LOG_NOTICE, cf->log, 0, "Foo Module is enabled"); return NGX_CONF_OK; } ``` -------------------------------- ### Install Angie on OSNova Source: https://cn.angie.software/angie/docs/installation/oss_packages Installs the Angie web server on OSNova. This process includes installing necessary prerequisites, fetching the Angie GPG key, adding the Angie repository configured for OSNova, and finally installing the 'angie' package. ```bash $ sudo apt-get update $ sudo apt-get install -y ca-certificates curl $ sudo curl -o /etc/apt/trusted.gpg.d/angie-signing.gpg \ https://angie.software/keys/angie-signing.gpg $ echo "deb https://download.angie.software/angie/osnova/$(egrep -o \ '[0-9]*' /etc/osnova_version | head -1) \ $(. /etc/os-release && echo "$VERSION_CODENAME") main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null $ sudo apt-get update $ sudo apt-get install -y angie ``` -------------------------------- ### Update Package Index and Install Angie PRO on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Updates the local package index to include packages from the newly added Angie PRO repository and then installs the 'angie-pro' package. An optional step to install additional packages is also included. ```bash $ sudo apt-get update $ sudo apt-get install -y angie-pro $ sudo apt-get install -y ``` -------------------------------- ### Mirror Module Configuration Source: https://cn.angie.software/angie/docs/configuration/modules/http/http_mirror This section provides configuration examples for the Mirror module, demonstrating how to set up request mirroring. ```APIDOC ## Mirror Module Configuration This module mirrors original requests to a backend by creating mirror subrequests. Responses to mirror subrequests are ignored. ### Configuration Example ```nginx location / { mirror /mirror; proxy_pass http://backend; } location = /mirror { internal; proxy_pass http://test_backend$request_uri; } ``` ``` -------------------------------- ### Check Angie Installation Version Source: https://cn.angie.software/angie/docs/configuration/migration Verifies the installation of Angie and displays its version along with the Nginx version it's built upon. This command is essential after installing Angie from a package to ensure correct setup. ```bash $ sudo angie -V Angie version: Angie/1.10.3 nginx version: nginx/1.27.5 built by gcc 11.4.0 configure arguments: --prefix=/etc/angie --conf-path=/etc/angie/angie.conf ... ``` -------------------------------- ### Reboot Server After Digsig Key Install on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Reboots the server to apply the changes made by the initramfs update. This step is crucial after installing the digsig key and updating initramfs in CSE mode. ```bash $ sudo shutdown -r now ``` -------------------------------- ### Build and Install Angie Source: https://cn.angie.software/angie/docs/installation/sourcebuild Compiles the Angie source code using the generated Makefile and then installs the application. This step requires the Makefile to be successfully created by the ./configure script. ```bash $ make $ make install ``` -------------------------------- ### Angie Configuration File Structure Example Source: https://cn.angie.software/angie/docs/configuration/configfile Demonstrates the hierarchical structure of an Angie configuration file, including main, events, http, server, and location contexts. It shows how directives are placed within these contexts and how to use include statements for modular configuration. ```nginx user angie; # Directive in 'main' context events { # Configuration for connection processing } http { # HTTP-specific configuration affecting all virtual servers server { # Configuration for HTTP virtual server 1 location /one { # Configuration for URIs starting with '/one' } location /two { # Configuration for URIs starting with '/two' } } server { # Configuration for HTTP virtual server 2 } } stream { # TCP/UDP-specific configuration affecting all virtual servers server { # Configuration for TCP virtual server 1 } } ``` -------------------------------- ### Angie Configuration Examples for Echo Module Source: https://cn.angie.software/angie/docs/installation/external-modules/echo A collection of Nginx configuration blocks demonstrating the various directives provided by the Echo module. These examples showcase how to insert content before and after the body, implement delays with echo_sleep, duplicate output, and manage timers for asynchronous operations. ```nginx server { listen 80; server_name localhost; location /echo { echo_before_body 'These lines are inserted by'; echo_before_body 'echo_before_body directive'; echo_after_body 'These lines are added by'; echo_after_body 'echo_after_body directive'; proxy_pass $scheme://127.0.0.1:$server_port$request_uri/more; } location /echo/more { set $val 'value'; echo '======== Backend Response Start ========='; echo 'Backend response body'; echo "val is set to $val"; echo '======== Backend Response End ==========='; } location /echo_with_sleep { echo hello; echo_flush; echo_sleep 2.5; echo world; } location /dup { echo_duplicate 3 "--"; echo_duplicate 1 " END "; echo_duplicate 3 "--"; echo; } location /subr { echo_reset_timer; echo_location /sub1; echo_location /sub2; echo "took $echo_timer_elapsed sec for total."; } location /subr_async { echo_reset_timer; echo_location_async /sub1; echo_location_async /sub2; echo "took $echo_timer_elapsed sec for total."; } location /sub1 { echo_sleep 2; echo hello; } location /sub2 { echo_sleep 1; echo world; } } ``` -------------------------------- ### Update Initramfs after Digsig Key Install on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Updates the initial RAM filesystem (initramfs) for all kernels. This is necessary after installing the Angie PRO digital signature key, especially in CSE mode, to ensure the system recognizes the changes. ```bash $ sudo update-initramfs -uk all ``` -------------------------------- ### Install Angie PRO Digsig Key for CSE on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Installs the digital signature key package for Angie PRO, specifically for use in Closed Software Environment (CSE) mode. This is an optional step for verifying the authenticity of Angie PRO executables. ```bash $ sudo apt-get install -y angie-digsig-key ``` -------------------------------- ### Copy ModSecurity CRS Configuration Examples Source: https://cn.angie.software/angie/docs/installation/external-modules/modsecurity These commands copy the example configuration files from the OWASP ModSecurity CRS. This includes the main setup file and exclusion rule files, which are necessary for ModSecurity to function correctly with CRS. ```bash $ sudo cp coreruleset/crs-setup.conf.example coreruleset/crs-setup.conf $ sudo cp coreruleset/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example \ coreruleset/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf $ sudo cp coreruleset/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example \ coreruleset/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf ``` -------------------------------- ### Angie Basic Listen Configurations Source: https://cn.angie.software/angie/docs/configuration/modules/http Demonstrates basic configurations for the 'listen' directive in Angie, including specifying IP addresses, ports, and using hostnames. These examples showcase how to bind the server to specific network interfaces and ports. ```nginx listen 127.0.0.1:8000; listen 127.0.0.1; listen 8000; listen *:8000; listen localhost:8000; ``` -------------------------------- ### Update Angie PRO Package on FreeBSD (Advanced) Source: https://cn.angie.software/angie/docs/installation/pro_packages Provides an advanced command to upgrade the Angie PRO package on FreeBSD by dynamically searching for the latest version and installing it. This is useful if the standard 'pkg upgrade' does not pick up the latest version. ```bash $ sudo pkg upgrade `pkg search -r angie angie-pro-[0-9] | sort -Vr | head -1 | awk {'print $1'}` ``` -------------------------------- ### Angie 'limit_conn_zone' Directive Setup Source: https://cn.angie.software/angie/docs/configuration/modules/stream/stream_limit_conn Demonstrates the setup of a shared memory zone using the 'limit_conn_zone' directive in Angie. This zone stores the state of various keys, including the current connection count. The example uses the `$binary_remote_addr` variable to track connections per client IP address. ```nginx limit_conn_zone $binary_remote_addr zone=addr:10m; ``` -------------------------------- ### Angie Connection Read Handler Example (C) Source: https://cn.angie.software/angie/docs/development Provides a C code example demonstrating a connection read handler. It shows how to add a timer to the read event, set a handler, receive data using c->recv, and manage the read event using ngx_handle_read_event. ```c void ngx_my_connection_read(ngx_connection_t *c) { ngx_event_t *rev; rev = c->read; ngx_add_timer(rev, 1000); rev->handler = ngx_my_read_handler; ngx_my_read(rev); } void gx_my_read_handler(ngx_event_t *rev) { ssize_t n; ngx_connection_t *c; u_char buf[256]; if (rev->timedout) { /* timeout expired */ } c = rev->data; while (rev->ready) { n = c->recv(c, buf, sizeof(buf)); if (n == NGX_AGAIN) { break; } if (n == NGX_ERROR) { /* error */ } /* process buf */ } if (ngx_handle_read_event(rev, 0) != NGX_OK) { /* error */ } } ``` -------------------------------- ### Get Value from Shared Memory Source: https://cn.angie.software/angie/docs/installation/external-modules/keyval Example using curl to retrieve a value associated with a key from the 'one' shared memory zone using the Keyval module. ```bash $ curl "localhost/get/?key=one" key 'one' has value = 'TextForKeyOne' ``` -------------------------------- ### Configure Angie Build Options Source: https://cn.angie.software/angie/docs/installation/sourcebuild Prepares the build environment by running the configure script with specified options. This script determines system-specific features and creates a Makefile. Review and set desired build options before execution. ```bash $ ./configure ``` -------------------------------- ### Set Permissions for SSL Directory on Astra SE Source: https://cn.angie.software/angie/docs/installation/pro_packages Changes the ownership and group of the /etc/ssl/angie/ directory and its contents to '_apt:nogroup'. This is a security measure to restrict access to the SSL files. ```bash $ sudo chown -R _apt:nogroup /etc/ssl/angie/ ``` -------------------------------- ### Angie Queue Example: Insertion and Traversal (C) Source: https://cn.angie.software/angie/docs/development Provides a practical example of using Angie queues. It defines a sample struct `ngx_foo_t` containing a `ngx_queue_t` member, demonstrates inserting a node into the queue using `ngx_queue_insert_tail`, and then iterates through the queue using `ngx_queue_head`, `ngx_queue_sentinel`, and `ngx_queue_data`. ```c typedef struct { ngx_str_t value; ngx_queue_t queue; } ngx_foo_t; ngx_foo_t *f; gx_queue_t values, *q; ngx_queue_init(&values); f = ngx_palloc(pool, sizeof(ngx_foo_t)); if (f == NULL) { /* error */ } ngx_str_set(&f->value, "foo"); gx_queue_insert_tail(&values, &f->queue); /* insert more nodes here */ for (q = ngx_queue_head(&values); q != ngx_queue_sentinel(&values); q = ngx_queue_next(q)) { f = ngx_queue_data(q, ngx_foo_t, queue); ngx_do_smth(&f->value); } ``` -------------------------------- ### Install Angie on Astra SE Source: https://cn.angie.software/angie/docs/installation/oss_packages Installs the Angie web server on Astra SE by adding the Angie repository, importing the GPG key, and installing the 'angie' package. Includes optional steps for CSE environments and updating initramfs. ```bash $ sudo apt-get update $ sudo apt-get install -y ca-certificates curl lsb-release $ sudo curl -o /etc/apt/trusted.gpg.d/angie-signing.gpg \ https://angie.software/keys/angie-signing.gpg $ echo "deb https://download.angie.software/angie/astra-se/$(egrep -o \ '[0-9]+.[0-9]+' /etc/astra_version) unstable main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null $ sudo apt-get update $ sudo apt-get install -y angie $ sudo update-initramfs -uk all $ sudo shutdown -r now ``` -------------------------------- ### API MethodNotAllowed Error Example Source: https://cn.angie.software/angie/docs/configuration/modules/http/http_api Demonstrates the JSON response when an unsupported HTTP method (e.g., POST) is used with the API module. The API typically only supports GET and HEAD requests. ```json { "error": "MethodNotAllowed", "description": "The POST method is not allowed for the requested API element \"/\".." } ``` -------------------------------- ### Enabling Angie Service to Start on Boot Source: https://cn.angie.software/angie/docs/configuration/migration This command configures the Angie service to automatically start whenever the system boots up. This is a recommended step after a successful migration to ensure continuous operation. ```bash $ sudo systemctl enable angie ``` -------------------------------- ### Deploy OIDC Authentication with Docker Source: https://cn.angie.software/angie/docs/configuration/oidc Command to start the Docker services in detached mode, essential for deploying the OIDC authentication setup. This command initiates the necessary containers for the application to run. ```bash $ docker-compose up -d ``` -------------------------------- ### Install Angie on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/oss_packages Installs the Angie web server on Debian and Ubuntu systems. It involves updating package lists, installing prerequisites, adding the Angie repository with the GPG key, and then installing the 'angie' package. ```bash $ sudo apt-get update $ sudo apt-get install -y ca-certificates curl $ sudo curl -o /etc/apt/trusted.gpg.d/angie-signing.gpg \ https://angie.software/keys/angie-signing.gpg $ echo "deb https://download.angie.software/angie/$(. /etc/os-release && echo "$ID/$VERSION_ID $VERSION_CODENAME") main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null $ sudo apt-get update $ sudo apt-get install -y angie ``` -------------------------------- ### Specialized Angie Build with Advanced Modules Source: https://cn.angie.software/angie/docs/installation/sourcebuild This comprehensive build includes HTTPS, HTTP/2, compression, enhanced security, and performance features. It is optimized for HTTP and TCP/UDP proxying and integrates Brotli compression and cache management modules. It specifies detailed paths for installation and logging, and requires PCRE, zlib, OpenSSL, and third-party modules like ngx_brotli and ngx_cache_purge. ```bash $ ./configure \ --prefix=/usr/local/angie \ --sbin-path=/usr/sbin/angie \ --conf-path=/etc/angie/angie.conf \ --pid-path=/run/angie.pid \ --lock-path=/var/lock/angie.lock \ --error-log-path=/var/log/angie/error.log \ --http-log-path=/var/log/angie/access.log \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-threads \ --with-file-aio \ --with-stream \ --with-stream_ssl_module \ --with-pcre=../pcre2-10.40 \ --with-pcre-jit \ --with-zlib=../zlib-1.3 \ --with-openssl=../openssl-3.0.8 \ --with-openssl-opt="enable-ec_nistp_64_gcc_128" \ --add-module=../ngx_brotli \ --add-dynamic-module=../ngx_cache_purge ``` -------------------------------- ### Add Angie PRO Repository to Sources List on Debian/Ubuntu Source: https://cn.angie.software/angie/docs/installation/pro_packages Adds the Angie PRO repository to the system's package sources list. It dynamically determines the OS version and codename to ensure compatibility. ```bash $ echo "deb https://download.angie.software/angie-pro/$(. /etc/os-release && echo "$ID/$VERSION_ID $VERSION_CODENAME") main" \ | sudo tee /etc/apt/sources.list.d/angie.list > /dev/null ```