多个站点使用端口而不是域

我有一个没有域的服务器,但我想在那里运行几个网站。 我想用端口来代替域。

我为此端口设置了一个站点,并将应用程序目录设置为根目录,但是现在当我尝试访问http://127.0.0.1:81 ,服务器将我转到http://127.0.0.1:81/magento然后打破我的申请url。 为什么nginx会这样做?

我的这个网站的configuration是:

  server { listen 81; root /usr/share/nginx/www/magento; location / { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location ^~ /app/ { deny all; } location ^~ /includes/ { deny all; } location ^~ /lib/ { deny all; } location ^~ /media/downloadable/ { deny all; } location ^~ /pkginfo/ { deny all; } location ^~ /report/config.xml { deny all; } location ^~ /var/ { deny all; } location /var/export/ { auth_basic "Restricted"; auth_basic_user_file htpasswd; autoindex on; } location /. { return 404; } location @handler { rewrite / /index.php; } location ~ .php/ { rewrite ^(.*.php)/ $1 last; } location ~ .php$ { if (!-e $request_filename) { rewrite / /index.php last; } expires off; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param MAGE_RUN_CODE default; fastcgi_param MAGE_RUN_TYPE store; include fastcgi_params; } } 

正如Felix在上面的评论中提到的,一些应用程序为您重写了URL。 一种方法来检查这将是执行

 wget http://127.0.0.1:81 

并看看你是否得到一个301/302redirect到

 http://127.0.0.1:81/magento 

这个configuration文件中没有任何东西似乎表明nginx是问题,所以我会检查应用程序本身。