nginx_php
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версияСледующая версия | Предыдущая версия | ||
nginx_php [18.05.2025 18:27] – augin | nginx_php [19.05.2025 06:52] (текущий) – [nginx] augin | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | ====== install ====== | ||
+ | |||
<code bash> | <code bash> | ||
opkg install nginx | opkg install nginx | ||
Строка 104: | Строка 106: | ||
<code bash> | <code bash> | ||
- | mkdir -p / | + | / |
- | cat > "/ | + | |
- | map \$ssl_preread_server_name \$sni_name { | + | |
- | hostnames; | + | |
- | ${reality_domain} | + | |
- | ${domain} | + | |
- | default | + | |
- | } | + | |
- | + | ||
- | upstream xray { | + | |
- | server 127.0.0.1: | + | |
- | } | + | |
- | + | ||
- | upstream www { | + | |
- | server 127.0.0.1: | + | |
- | } | + | |
- | + | ||
- | server { | + | |
- | proxy_protocol on; | + | |
- | set_real_ip_from unix:; | + | |
- | listen | + | |
- | proxy_pass | + | |
- | ssl_preread | + | |
- | } | + | |
- | + | ||
- | EOF | + | |
- | + | ||
- | grep -xqFR " | + | |
- | grep -xqFR " | + | |
- | grep -xqFR " | + | |
- | grep -xqFR " | + | |
- | sed -i "/ | + | |
- | cat > "/ | + | |
- | server { | + | |
- | listen 80; | + | |
- | server_name ${domain} ${reality_domain}; | + | |
- | return 301 https:// | + | |
- | } | + | |
- | EOF | + | |
- | + | ||
- | + | ||
- | cat > "/ | + | |
server { | server { | ||
- | server_tokens off; | + | |
- | server_name | + | server_name |
- | listen | + | |
- | listen [::]:7443 ssl http2 proxy_protocol; | + | listen [::]:80; |
- | index index.html index.htm index.php index.nginx-debian.html; | + | |
- | root / | + | listen [::]:443 ssl http2; |
- | ssl_protocols TLSv1.2 TLSv1.3; | + | # |
- | ssl_ciphers HIGH: | + | |
- | ssl_certificate / | + | root / |
- | ssl_certificate_key / | + | ssl_protocols TLSv1.2 TLSv1.3; |
- | if (\$host !~* ^(.+\.)?$domain\$ ){return 444;} | + | ssl_ciphers HIGH: |
- | if (\$scheme ~* https) {set \$safe 1;} | + | ssl_certificate / |
- | if (\$ssl_server_name !~* ^(.+\.)?$domain\$ ) {set \$safe "\${safe}0"; | + | ssl_certificate_key / |
- | if (\$safe = 10){return 444;} | + | if ($host !~* ^(.+\.)?YOU_DOMAIN$ ){return 444;} |
- | if (\$request_uri ~ " | + | if ($scheme ~* https) {set $safe 1;} |
- | error_page 400 401 402 403 500 501 502 503 504 =404 /404; | + | if ($ssl_server_name !~* ^(.+\.)?YOU_DOMAIN$ ) {set $safe " |
- | proxy_intercept_errors on; | + | if ($safe = 10){return 444;} |
- | #X-UI Admin Panel | + | if ($request_uri ~ " |
- | location / | + | error_page 400 402 403 500 501 502 503 504 =404 /404; |
- | proxy_redirect off; | + | proxy_intercept_errors on; |
- | proxy_set_header Host \$host; | + | #X-UI Admin Panel |
- | proxy_set_header X-Real-IP \$remote_addr; | + | location /RANDOM_STRING/ { |
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | + | #auth_basic " |
- | proxy_pass http:// | + | #auth_basic_user_file |
- | break; | + | |
- | } | + | |
- | location /${panel_path} { | + | |
- | proxy_redirect off; | + | |
- | proxy_set_header Host \$host; | + | |
- | proxy_set_header X-Real-IP \$remote_addr; | + | |
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | + | |
- | proxy_pass http:// | + | |
- | break; | + | |
- | } | + | |
- | #sub2sing-box | + | |
- | location / | + | |
- | proxy_redirect off; | + | |
- | proxy_set_header Host \$host; | + | |
- | proxy_set_header X-Real-IP \$remote_addr; | + | |
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | + | |
- | proxy_pass http:// | + | |
- | } | + | |
- | | + | |
- | location ~ ^/${web_path}/clashmeta/(.+)$ { | + | |
- | default_type text/plain; | + | |
- | ssi on; | + | |
- | ssi_types text/ | + | |
- | set \$subid \$1; | + | |
- | root / | + | |
- | try_files /clash.yaml =404; | + | |
- | } | + | |
- | # web | + | |
- | location ~ ^/ | + | |
- | root / | + | |
- | index index.html; | + | |
- | try_files \$uri \$uri/ /index.html =404; | + | |
- | } | + | |
- | | + | |
- | location / | + | |
- | if (\$hack = 1) {return 404;} | + | |
proxy_redirect off; | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | + | proxy_set_header Host $host; |
- | proxy_set_header X-Real-IP | + | proxy_set_header X-Real-IP $remote_addr; |
- | proxy_set_header X-Forwarded-For | + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
- | proxy_pass http:// | + | proxy_pass http:// |
break; | break; | ||
} | } | ||
- | location /${sub_path}/ | + | # |
- | if (\$hack = 1) {return 404;} | + | |
+ | if ($hack = 1) {return 404;} | ||
proxy_redirect off; | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | + | proxy_set_header Host $host; |
- | proxy_set_header X-Real-IP | + | proxy_set_header X-Real-IP $remote_addr; |
- | proxy_set_header X-Forwarded-For | + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
- | proxy_pass http:// | + | proxy_pass http:// |
break; | break; | ||
} | } | ||
- | # | + | |
- | location /${json_path} | + | location |
- | if (\$hack = 1) {return 404;} | + | if ($hack = 1) {return 404;} |
proxy_redirect off; | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | + | proxy_set_header Host $host; |
- | proxy_set_header X-Real-IP | + | proxy_set_header X-Real-IP $remote_addr; |
- | proxy_set_header X-Forwarded-For | + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
- | proxy_pass http:// | + | proxy_pass http:// |
break; | break; | ||
} | } | ||
- | location /${json_path}/ { | + | #Xray Config Path |
- | if (\$hack = 1) {return 404;} | + | |
- | | + | if ($hack = 1) {return 404;} |
- | proxy_set_header Host \$host; | + | |
- | proxy_set_header X-Real-IP | + | #if ($http_cf_ipcountry !~* " |
- | proxy_set_header X-Forwarded-For | + | #if ($http_user_agent ~* " |
- | proxy_pass http:// | + | client_max_body_size 0; |
+ | client_body_timeout 1d; | ||
+ | grpc_read_timeout 1d; | ||
+ | grpc_socket_keepalive on; | ||
+ | proxy_read_timeout 1d; | ||
+ | proxy_http_version 1.1; | ||
+ | proxy_buffering | ||
+ | proxy_request_buffering off; | ||
+ | proxy_socket_keepalive on; | ||
+ | proxy_set_header Upgrade $http_upgrade; | ||
+ | proxy_set_header Connection " | ||
+ | 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 ($content_type ~* " | ||
+ | proxy_pass http:// | ||
break; | break; | ||
} | } | ||
- | #XHTTP | + | |
- | location / | + | |
- | grpc_pass grpc:// | + | |
- | grpc_buffer_size | + | |
- | grpc_socket_keepalive | + | |
- | grpc_read_timeout | + | |
- | grpc_send_timeout | + | |
- | grpc_set_header Connection | + | |
- | grpc_set_header X-Forwarded-For | + | |
- | grpc_set_header X-Forwarded-Proto | + | |
- | grpc_set_header X-Forwarded-Port | + | |
- | grpc_set_header Host | + | |
- | grpc_set_header X-Forwarded-Host | + | |
- | } | + | |
- | | + | |
- | location ~ ^/ | + | |
- | $CF_IP if (\$cloudflare_ip != 1) {return 404;} | + | |
- | if (\$hack = 1) {return 404;} | + | |
- | client_max_body_size 0; | + | |
- | client_body_timeout 1d; | + | |
- | grpc_read_timeout 1d; | + | |
- | grpc_socket_keepalive on; | + | |
- | proxy_read_timeout 1d; | + | |
- | proxy_http_version 1.1; | + | |
- | proxy_buffering off; | + | |
- | proxy_request_buffering off; | + | |
- | proxy_socket_keepalive on; | + | |
- | proxy_set_header Upgrade \$http_upgrade; | + | |
- | proxy_set_header Connection " | + | |
- | 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 (\$content_type ~* " | + | |
- | grpc_pass grpc:// | + | |
- | break; | + | |
- | } | + | |
- | if (\$http_upgrade ~* " | + | |
- | proxy_pass http:// | + | |
- | break; | + | |
- | } | + | |
- | if (\$request_method ~* ^(PUT|POST|GET)\$) { | + | |
- | proxy_pass http:// | + | |
- | break; | + | |
- | } | + | |
- | } | + | |
- | location / { try_files | + | |
} | } | ||
- | EOF | ||
- | |||
- | cat > "/ | ||
- | server { | ||
- | server_tokens off; | ||
- | server_name ${reality_domain}; | ||
- | listen 9443 ssl http2; | ||
- | listen [::]:9443 ssl http2; | ||
- | index index.html index.htm index.php index.nginx-debian.html; | ||
- | root / | ||
- | ssl_protocols TLSv1.2 TLSv1.3; | ||
- | ssl_ciphers HIGH: | ||
- | ssl_certificate / | ||
- | ssl_certificate_key / | ||
- | if (\$host !~* ^(.+\.)? | ||
- | if (\$scheme ~* https) {set \$safe 1;} | ||
- | if (\$ssl_server_name !~* ^(.+\.)? | ||
- | if (\$safe = 10){return 444;} | ||
- | if (\$request_uri ~ " | ||
- | error_page 400 401 402 403 500 501 502 503 504 =404 /404; | ||
- | proxy_intercept_errors on; | ||
- | #X-UI Admin Panel | ||
- | location / | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | location / | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | # | ||
- | location / | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | } | ||
- | # Path to open clash.yaml and generate YAML | ||
- | location ~ ^/ | ||
- | default_type text/plain; | ||
- | ssi on; | ||
- | ssi_types text/plain; | ||
- | set \$subid \$1; | ||
- | root / | ||
- | try_files /clash.yaml =404; | ||
- | } | ||
- | # web | ||
- | location ~ ^/ | ||
- | root / | ||
- | index index.html; | ||
- | try_files \$uri \$uri/ /index.html =404; | ||
- | } | ||
- | | ||
- | location / | ||
- | if (\$hack = 1) {return 404;} | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | location / | ||
- | if (\$hack = 1) {return 404;} | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | # | ||
- | location / | ||
- | if (\$hack = 1) {return 404;} | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | location / | ||
- | if (\$hack = 1) {return 404;} | ||
- | proxy_redirect off; | ||
- | proxy_set_header Host \$host; | ||
- | proxy_set_header X-Real-IP \$remote_addr; | ||
- | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | #XHTTP | ||
- | location / | ||
- | grpc_pass grpc:// | ||
- | grpc_buffer_size | ||
- | grpc_socket_keepalive | ||
- | grpc_read_timeout | ||
- | grpc_send_timeout | ||
- | grpc_set_header Connection | ||
- | grpc_set_header X-Forwarded-For | ||
- | grpc_set_header X-Forwarded-Proto | ||
- | grpc_set_header X-Forwarded-Port | ||
- | grpc_set_header Host | ||
- | grpc_set_header X-Forwarded-Host | ||
- | } | ||
- | | ||
- | location ~ ^/ | ||
- | $CF_IP if (\$cloudflare_ip != 1) {return 404;} | ||
- | if (\$hack = 1) {return 404;} | ||
- | client_max_body_size 0; | ||
- | client_body_timeout 1d; | ||
- | grpc_read_timeout 1d; | ||
- | grpc_socket_keepalive on; | ||
- | proxy_read_timeout 1d; | ||
- | proxy_http_version 1.1; | ||
- | proxy_buffering off; | ||
- | proxy_request_buffering off; | ||
- | proxy_socket_keepalive on; | ||
- | proxy_set_header Upgrade \$http_upgrade; | ||
- | proxy_set_header Connection " | ||
- | 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 (\$content_type ~* " | ||
- | grpc_pass grpc:// | ||
- | break; | ||
- | } | ||
- | if (\$http_upgrade ~* " | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | if (\$request_method ~* ^(PUT|POST|GET)\$) { | ||
- | proxy_pass http:// | ||
- | break; | ||
- | } | ||
- | } | ||
- | location / { try_files \$uri \$uri/ =404; } | ||
- | } | ||
- | EOF | ||
</ | </ | ||
nginx_php.1747592822.txt.gz · Последнее изменение: — augin