配置虚拟机端口
1 添加iptables端口 vi /etc/sysconfig/iptables 找到 -A INPUT -s 172.16.0.0/16 这一行,加入新加的端口
2 重启iptables /etc/init.d/iptables restart
3 添加rewrite配置文件 在/usr/local/etc/openresty/sites-available 下创建文件
如 http-appadmin.conf
内容如下
server
{
listen 8089;
index index.html index.php;
root /var/www/cloudplatform/appstore/public/app/;
location / {
index index.html index.php;
}
location ~ \.php$ {
#auth_request /auth;
fastcgi_pass php-fcgi;
include fastcgi.conf;
}
}
4建立软连接到sites-enable里去
ln -s /usr/local/etc/openresty/sites-available/http-appadmin.conf /usr/local/etc/openresty/sites-enable/http-appadmin.conf
5重启nginx
rewrite规则:
server {
listen 8088;
charset utf-8;
gzip on;
gzip_types text/plain application/json;
gzip_proxied no_etag;
error_log /var/log/openresty/api.appstore.smartisan.cn_error.log;
access_log /var/log/openresty/api.appstore.smartisan.cn_access.log;
root /var/www/cloudplatform/appstore/public/api;
location / {
rewrite /category/list.json /appstore.php?c=category last;
if ($request_method = DELETE) {
rewrite /collect/([1-9][0-9]*).json /appstore.php?c=delCollect&aid=$1 last; #删除心愿单
return 403;
}
return 404;
}
#排行榜
location /top {
rewrite /top/size/([1-9][0-9]*)/page/([1-9][0-9]*)/list.json /appstore.php?c=top&size=$1&page=$2 last;
rewrite /top/size/([1-9][0-9]*)/list.json /appstore.php?c=top&size=$1 last;
}
#通过专题ID获取推荐列表
location ~*/([1-9][0-9]*)/topic{
rewrite /([1-9][0-9]*)/topic/size/([1-9][0-9]*)/page/([1-9][0-9]*)/list.json /appstore.php?c=getAppByTopic&tid=$1&size=$2&page=$3 last;
rewrite /([1-9][0-9]*)/topic/size/([1-9][0-9]*)/list.json /appstore.php?c=getAppByTopic&tid=$1&size=$2 last;
}
location ~*\.ico$ {
return 404;
}
location = /auth {
internal;
return 401;
}
location ~ \.php$ {
#auth_request /auth;
fastcgi_pass php-fcgi;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}