最近需要用到 Openwrt/Lede 下的 nginx,opkg install nginx 安装的包并不支持 https 和 http2,需要自己编译,尝试用英文记录:

Install nginx adopt this command in openwrt:

opkg install nginx

But this nginx version without http_ssl_module,that means it does not support HTTPS.

Cross-compile nginx:

Prerequisites:

Do everything as non-root user!
Don't compile in Linux Subsystem on Windows 10
1-4 GB of RAM to build Openwrt
  1. Install build tools to do the cross-compilation process

    apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev subversion libncurses5-dev gcc-multilib flex gettext  mercurial
    
    
  2. Download the OpenWrt source code

    git clone https://github.com/openwrt/openwrt.git
    
  3. Setup the Build System,select your router types like this

    cd openwrt  
    make menuconfig  

    TIM截图20180315201414.png

    make V=s
    

    make V=s may spend half an hour...

  4. Compile nginx ipk

    scripts/feeds update
    scripts/feeds search nginx
    scripts/feeds install nginx
    make menuconfig
        network
            Web Servers/Proxies
                nginx : select M
                   nginx: ENTER
                        Configuration
                        Enable SSL module : Y
                        save & exit
    time make -j5

    If you want to deploy HTTP2, choose Enable http_v2_module at the sametime.
    Compile peocess may spend 10 minutes.

  5. Then search nginx ipk file,copy it to router and install

    find . -type f -name nginx\*ipk
    

    You can use the "ssl on" directive in /etc/nginx/nginx.conf.