Php Node.js应用程序的服务器配置

Php Node.js应用程序的服务器配置,php,node.js,apache,configuration-files,Php,Node.js,Apache,Configuration Files,我正在尝试将一个应用程序从PHP移到Node.js上。PHP应用程序使用Apache服务器,并具有应用程序工作所必需的tileservices.conf文件。如何将此文件中的配置移动到节点应用程序 Alias /tiles /sandbox/TileServices/www/TileStreamer.php Alias /thumbs /sandbox/TileServices/www/ThumbStreamer.php Alias /MosaicTest /sandbox/TileServic

我正在尝试将一个应用程序从PHP移到Node.js上。PHP应用程序使用Apache服务器,并具有应用程序工作所必需的
tileservices.conf
文件。如何将此文件中的配置移动到节点应用程序

Alias /tiles /sandbox/TileServices/www/TileStreamer.php
Alias /thumbs /sandbox/TileServices/www/ThumbStreamer.php
Alias /MosaicTest /sandbox/TileServices/www/MosaicTest

RewriteEngine on
RewriteRule ^/1.0.0/([a-zA-Z0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)\.[a-zA-Z]*$ /sandbox/TileServices/tiles/tc/cache_server.php?z=$2&c=$3&r=$4&cache=$1
RewriteRule ^/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=$2&c=$3&r=$4&cache=$1
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)$ /sandbox/TileServices/www/tc/cache_server_new.php?z=$2&c=$3&r=$4&cache=$1&do_not_cache=nocache
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=$2&c=$3&r=$4&cache=$1&do_not_cache=nocache

RewriteRule ^/oms/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=$2&c=$3&r=$4&library=$1&filestyle=strip
RewriteRule ^/omb/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=$2&c=$3&r=$4&library=$1&filestyle=block
RewriteRule ^/ms/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=$3&c=$4&r=$5&resource=$1&tkid=$2&filestyle=strip
RewriteRule ^/mb/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=$3&c=$4&r=$5&resource=$1&tkid=$2&filestyle=block

<Directory "/sandbox/TileServices/www">
    AllowOverride None
    Options -Indexes
    Require all granted

    <IfModule speling>
        CheckSpelling on
    </IfModule>

    SetEnv MOUNT_PREFIX "/mnt/autofs"
</Directory>

<Directory "/sandbox/TileServices/www/tiles/MosaicTest">
    Require all denied
    Allow from 10.0.0.0/8
    Allow from 172.16.0.0/12
    Allow from 192.168.0.0/16
    Allow from 206.90.52.6/32
</Directory>
Alias/tiles/sandbox/TileServices/www/TileStreamer.php
别名/thumbs/sandbox/TileServices/www/ThumbStreamer.php
Alias/MosaicTest/sandbox/TileServices/www/MosaicTest
重新启动发动机
重写规则^/1.0.0/([a-zA-Z0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)\.[a-zA-Z]*$/sandbox/TileServices/tiles/tc/cache_server.php?Z=$2&c=$3&r=$4&cache=$1
重写规则^/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$/sandbox/TileServices/www/tc/cache\u server\u new.php?Z=$2&c=$3&r=$4&cache=$1
重写规则^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)$/sandbox/TileServices/www/tc/cache\u server\u new.php?z=$2&c=$3&r=$4&cache=$1&do\u cache=nocache
重写规则^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$/sandbox/TileServices/www/tc/cache\u server\u new.php?Z=$2&c=$3&r=$4&cache=$1&do\u not\u cache=nocache
重写规则^/oms/1.0.0/(.+)/(.+)/(.+)/(.+)\[a-zA-Z]*$/sandbox/TileServices/www/MosaicRequestHandler.php?Z=$2&c=$3&r=$4&library=$1&filestyle=strip
重写规则^/omb/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$/sandbox/TileServices/www/MosaicRequestHandler.php?Z=$2&c=$3&r=$4&library=$1&filestyle=block
重写规则^/ms/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$/sandbox/TileServices/www/Mosaic/Mosaic.php?Z=$3&c=$4&r=$5&resource=$1&tkid=$2&filestyle=strip
重写规则^/mb/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$/sandbox/TileServices/www/Mosaic/Mosaic.php?Z=$3&c=$4&r=$5&resource=$1&tkid=$2&filestyle=block
不允许超限
选项-索引
要求所有授权
拼写检查
SetEnv MOUNT_前缀“/mnt/autofs”
要求全部拒绝
允许从10.0.0.0/8开始
允许从172.16.0.0/12开始
允许从192.168.0.0/16开始
允许从206.90.52.6/32开始
编辑:

//大量的路由信息

对于第一部分(直到第一条2x新线)

您非常需要express执行以下操作:

app.get('/tiles', function (req, res) {
  res.send('GET request to /tiles'); //or some other logic
});
app.get('/thumbs', function (req, res) {
  res.send('GET request to /tiles'); //or some other logic
});
app.get('/MosaicTest', function (req, res) {
  res.send('GET request to /tiles'); //or some other logic
});
第二部分:

// ^/1.0.0/([a-zA-Z0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)\.[a-zA-Z]*$

app.get('/1.0.0/:param1/:param2/:param3/:param4', function (req, res) {
  var param1 =req.params.param1,
   param2 = req.params.param2,
   param3 = req.params.param3,
   param4 = req.params.param4;

  res.send('your first route parameter is '+param1); //or some other logic
});
第一部分可能不会有问题,因为Node.js不会提供目录和文件,除非您也对其进行编程。因此,您的服务器受到保护

第二部分,如果这些是文件(如图像),您可能需要考虑将它们发送到用户节点的方式。如果这些只是页面/其他数据,您将通过节点提供服务,那么您基本上需要过滤访问这些页面/数据的IP-s,以便按照

//    this goes after your route definition
// so after something like app.get('/MosaicTest', function (req, res) { 
var ip = req.ip; 
if (ip == '127.0.0.1') {
    res.send('ip not allowed');
    res.end();
}
// close route definition });
// source: http://stackoverflow.com/questions/12349251/restrict-access-to-node-js-based-http-server-by-ip-address
可能会有帮助

遗憾的是,我自己不是node.js专家,所以您需要寻找其他答案或提出更具体的问题来完成这一切


希望这一切对你有所帮助!:)

我们不再需要Apache和PHP了!一个是完全的PHP应用程序,它正被移动到完全的节点应用程序。我发布的文件是PHP应用程序使用的配置文件。我不知道如何将这些配置设置移动到节点应用程序中。我目前使用的是express,它处理路由,但不是服务器配置。我扩展了我的答案。你可能想试试express。它允许您执行类似于.htaccess的路由。我正在使用Express进行路由,但我不知道如何将其用于服务器配置。在我看来,前十几条线路完全可以通过Express方式完成。是你需要帮助的东西还是你发布的代码中的所有语句?几乎所有的东西!我是Apache和Node的新手-_-