App Inventor 2 离线服务器作为一个网站多用户使用的时候,有一个潜在的危险: /_ah/admin是公开访问的,所以我们需要一个代理服务器,屏蔽/_ah/admin,并且可以有针对性的提供一些其他服务。
一、下载文件(php 和 RunHiddenConsole 为将来准备):
php7 : http://windows.php.net/download VC14 x64 Thread Safe http://windows.php.net/downloads/releases/php-7.1.2-Win32-VC14-x64.zip (可选)
vc14: https://www.microsoft.com/zh-CN/download/details.aspx?id=48145 (vcruntime14)(可选)
RunHiddenConsole: http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip (可选)
Nginx-GUI-Administrator https://sourceforge.net/projects/nginxgui/files/latest/download (必须)
nginx: http://nginx.org/en/download.html Stable version http://nginx.org/download/nginx-1.10.3.zip(必须)
二、rundev.bat修改下
@echo off
echo "Starting App Inventor 2..."
cd %~dp0
".\jdk\jre7\bin\java" -cp ".\AppEngine\lib\appengine-tools-api.jar" com.google.appengine.tools.KickStart com.google.appengine.tools.development.DevAppServerMain %* --port=8888 --disable_update_check --address=127.0.0.1 Devserver
三、nginx和php解压到ai2server目录。
三、修改nginx\conf\nginx.conf 文件,不转发/_ah/admin目录。
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;server_tokens off; # 不发送版本号--> 新增
client_max_body_size 1280M; #新增
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;#keepalive_timeout 0;
keepalive_timeout 65;#gzip on;
server {
listen 80;
####改自己网站##
server_name ai2.fsyz.net;#charset koi8-r;
#access_log logs/host.access.log main;
root html;
location / {
proxy_pass http://127.0.0.1:8888/;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;##rewrite /dashboard/(.*) /$1 break;
##rewrite ^/dashboard$ /dashboard/ permanent;proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}location /_ah/admin {
index index.html index.htm;
}
location /_db {
index index.php index.html index.htm;
}location /passmail {
index index.php;
}location /mysql {
root html;
index index.php;
}
#error_page 404 /404.html;# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
四、运行nginx目录下nginxGUI.exe,点击start按钮。应该就可以看到效果了。
五、自己对应修改php\php.ini 网上很多资料
六、run_nginx_php.bat
@ECHO OFF
cd %~dp0
ECHO Starting PHP FastCGI...
set PHP_FCGI_MAX_REQUESTS=100
RunHiddenConsole.exe php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.iniecho Starting nginx...
RunHiddenConsole nginx\nginx.exe -p nginx
ping 127.0.0.1 -n 1>NUL
echo .
echo .
echo .
ping 127.0.0.1 >NUL
七、stop_nginx_php.bat
@ECHO OFF
taskkill /f /IM nginx.exe
taskkill /f /IM php-cgi.exe
EXIT
本站提供的个人修改版已经自带nginx和php : https://gte.fsyz.net/node/1878