Node.js 应用程序的服务器配置
Server configuration for Node.js application
我正在尝试将应用程序从 PHP 移到 Node.js。 PHP 应用程序使用 Apache 服务器并有一个应用程序运行所必需的 tileservices.conf
文件。我如何将此文件中的配置移至 Node 应用程序?
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=&c=&r=&cache=
RewriteRule ^/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=&do_not_cache=nocache
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=&do_not_cache=nocache
RewriteRule ^/oms/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=&c=&r=&library=&filestyle=strip
RewriteRule ^/omb/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=&c=&r=&library=&filestyle=block
RewriteRule ^/ms/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=&c=&r=&resource=&tkid=&filestyle=strip
RewriteRule ^/mb/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=&c=&r=&resource=&tkid=&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>
已编辑:
//关于路由的大量信息http://expressjs.com/en/guide/routing.html
第一部分(直到第一个 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 不会提供目录和文件,除非您也对它进行编程。所以您的服务器受到保护。
第二部分,如果这些是文件(如图像),您可能需要想办法通过节点将它们发送给用户。如果这些只是 pages/other 数据,你将通过 Node 提供服务,你基本上需要过滤访问它们的 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:
可能会有帮助
遗憾的是,我自己并不是 node.js 专家,因此您需要寻找其他答案或提出更具体的问题才能完成所有工作。
希望这一切对您有所帮助! :)
我正在尝试将应用程序从 PHP 移到 Node.js。 PHP 应用程序使用 Apache 服务器并有一个应用程序运行所必需的 tileservices.conf
文件。我如何将此文件中的配置移至 Node 应用程序?
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=&c=&r=&cache=
RewriteRule ^/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=&do_not_cache=nocache
RewriteRule ^/nocache/nwomtest/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/tc/cache_server_new.php?z=&c=&r=&cache=&do_not_cache=nocache
RewriteRule ^/oms/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=&c=&r=&library=&filestyle=strip
RewriteRule ^/omb/1.0.0/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/MosaicRequestHandler.php?z=&c=&r=&library=&filestyle=block
RewriteRule ^/ms/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=&c=&r=&resource=&tkid=&filestyle=strip
RewriteRule ^/mb/1.0.0/(.+)/(.+)/(.+)/(.+)/(.+)\.[a-zA-Z]*$ /sandbox/TileServices/www/Mosaic/Mosaic.php?z=&c=&r=&resource=&tkid=&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>
已编辑:
//关于路由的大量信息http://expressjs.com/en/guide/routing.html
第一部分(直到第一个 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 不会提供目录和文件,除非您也对它进行编程。所以您的服务器受到保护。
第二部分,如果这些是文件(如图像),您可能需要想办法通过节点将它们发送给用户。如果这些只是 pages/other 数据,你将通过 Node 提供服务,你基本上需要过滤访问它们的 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:
可能会有帮助
遗憾的是,我自己并不是 node.js 专家,因此您需要寻找其他答案或提出更具体的问题才能完成所有工作。
希望这一切对您有所帮助! :)