首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用apache将指定HTTPS请求重定向到特定端口

使用apache将指定HTTPS请求重定向到特定端口
EN

Stack Overflow用户
提问于 2018-05-31 16:17:45
回答 2查看 2.2K关注 0票数 1

我在将一些请求重定向到其他端口时遇到了问题。下面是我的配置:

  • 我有一个像XXXX.ddns.net
  • 这样的公共域我有一台安装了apache的Rapsbian服务器,我的/var/www文件夹中的文件都得到了正确的服务(angular网站)
  • 在同一台Raspbian服务器上有一台REST服务器在3000端口上运行
  • 这是在带Raspbian的HTTPS上运行的

我希望所有发送到XXXX.ddns.net/api/*的请求都被重定向到3000端口。

我更改了.htaccess文件,重写规则似乎可以在本地运行,但我不能在我的网站上运行。API请求实现时出现错误500。

这是我当前的.htaccess文件:

RewriteEngine On
RewriteRule ^api/(.*)      https://localhost:3000/api/$1 [QSA]
# not sure if it should be http or https in the rule but nothing works
#RewriteRule ^api/(.*)      http://localhost:3000/api/$1 [QSA]

# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested pattern is file and file doesn't exist, send 404
RewriteCond %{REQUEST_URI} ^(\/[a-z_\-\s0-9\.]+)+\.[a-zA-Z]{2,4}$
RewriteRule ^ - [L,R=404]

下面是我当前的000-default-le-ssl.conf文件(在/etc/apache2/sites available中):

<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

ServerName XXXX.ddns.net
SSLCertificateFile /etc/letsencrypt/live/XXXX.ddns.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/XXXX.ddns.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
<Location /api>
        ProxyPass http://127.0.0.1:3000/api
        ProxyPassReverse http://127.0.0.1:3000/api
</Location>

</VirtualHost>
</IfModule>

如果有人能帮我实现它..。谢谢!

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50619739

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档