worker_processes auto; user root; include module.d/*.module; events {} http { access_log off; log_format openwrt '$request_method $scheme://$host$request_uri => $status' ' (${body_bytes_sent}B in ${request_time}s) <- $http_referer'; include mime.types; default_type application/octet-stream; sendfile on; client_max_body_size 256M; large_client_header_buffers 2 1k; gzip on; gzip_vary on; gzip_proxied any; root /www; map $request_method:$query_string $login_request { default 0; ~^POST:istorenextlogin=1$ 1; ~^GET:istorenextlogin=1$ 2; } server { #see uci show 'nginx._redirect2ssl' listen 80; listen [::]:80; server_name _redirect2ssl; include restrict_locally; if ($login_request = 2) { return 302 $uri; } proxy_intercept_errors on; uwsgi_intercept_errors on; error_page 403 /cgi-bin/luci/istorenext-login; location ~ ^/cgi-bin/luci/istorenext(/|$) { include uwsgi_params; uwsgi_param SERVER_ADDR $server_addr; uwsgi_modifier1 9; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; if ($login_request = 0) { proxy_pass http://127.0.0.1:8080; } if ($login_request = 1) { uwsgi_pass unix:////var/run/luci-webui.socket; } } # configuration file /etc/nginx/conf.d/luci.locations: location /cgi-bin/luci { index index.html; include uwsgi_params; uwsgi_param SERVER_ADDR $server_addr; uwsgi_modifier1 9; uwsgi_pass unix:////var/run/luci-webui.socket; } access_log off; # logd openwrt; } }