【发布时间】:2015-10-21 21:04:34
【问题描述】:
我在 ubuntu VPS 上使用 apache 和 nginx。当我在那里托管网站时,Apache 具有端口 80 的优先级。
我有一个在端口 3000 上运行的小型 nodejs 应用程序。在 web 链接的目录中,我有一个 .htaccess 文件,该文件重定向到端口 8080(nginx 上的反向代理),但我仍然无法摆脱 :8080最后。
这是我的 .htaccess 文件
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://example.org:8080/$1 [R=301,L]
这是我的 nginx 配置
server {
listen 8080;
server_name example.org;
port_in_redirect off;
root /var/www/example.org/webapp;
access_log /var/www/example.org/log/access.log;
error_log /var/www/example.org/error.log;
location / {
proxy_pass http://example.org:3000;
proxy_redirect http://example.org:8080/ http://example.org/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
我尝试过关闭/不关闭 port_in_redirect;代理重定向http://example.org:8080/http://example.org/;
当我转到 example.org 时,它会重定向到 example.org:8080。有没有办法让 apache 和 nginx 共存而不会丢失我在 80 端口上的 apache 站点?
【问题讨论】:
标签: node.js apache .htaccess nginx