适用于 Ionic Framework 应用程序的 Apache proxypass
Apache proxypass for Ionic Framework app
我已经设法从外部设备访问内部 localhost:8100(ionic 服务器所在的位置),使用 proxypass 访问 192.168.1.130/ionic。我的 http-vhosts.conf:
<VirtualHost *:80>
ServerAdmin localhost@admin
DocumentRoot "/Volumes/DATA/03-www"
ServerName localhost
<Directory "/Volumes/DATA/03-www">
AllowOverride All
Require all granted
</Directory>
ProxyPreserveHost On
ProxyPass /ionic http://localhost:8100
ProxyPassReverse /ionic http://localhost:8100
</VirtualHost>
这里的问题是只有第一个请求 (index.html
) 被发送到离子服务器。来自此 index.html
的下一个请求将发送到 Apache,因为路径的开头不包括 /ionic
:
::1 - - [26/May/2015:21:00:31 +0200] "GET /ionic HTTP/1.1" 200 3097
::1 - - [26/May/2015:21:00:31 +0200] "GET /lib/ionic/css/ionic.css HTTP/1.1" 404 1265
::1 - - [26/May/2015:21:00:31 +0200] "GET /css/style.css HTTP/1.1" 404 1265
::1 - - [26/May/2015:21:00:31 +0200] "GET /fonts/font-awesome/css/font-awesome.min.css HTTP/1.1" 404 1265
有没有办法强制所有源自特定路径(匹配 proxypass)的请求通过代理,而无需修改 index.html
?
你有这样做的具体原因吗?因为如果没有并且您只需要在设备上检查您的应用程序,那么几乎没有其他选择。
您可以在您的设备中安装它(例如:IPhone),只要您的 phone 和开发机器(一个 运行 离子服务器)在同一网络中,你可以连接(没有电缆)
2 - Ionic View
当您想利用完整的本机功能时,您可以将您的应用程序发布到 ionic platform 并下载并安装到 Ionic View
3 - Ripple Emulator
一个 chrome 扩展,允许在浏览器中测试您的应用程序。它支持功能主义者,例如 GeoLocation
HTH
尝试在代理传递处添加斜杠,实际上在我的配置中,以下第一条规则运行良好
ProxyPass /ionic/ http://localhost:8100
在您的配置中,您可以试试这个:
<VirtualHost *:80>
ServerAdmin localhost@admin
DocumentRoot "/Volumes/DATA/03-www"
ServerName localhost
<Directory "/Volumes/DATA/03-www">
AllowOverride All
Require all granted
</Directory>
ProxyPreserveHost On
ProxyPass /ionic/ http://localhost:8100
ProxyPassReverse /ionic/ http://localhost:8100
我已经设法从外部设备访问内部 localhost:8100(ionic 服务器所在的位置),使用 proxypass 访问 192.168.1.130/ionic。我的 http-vhosts.conf:
<VirtualHost *:80>
ServerAdmin localhost@admin
DocumentRoot "/Volumes/DATA/03-www"
ServerName localhost
<Directory "/Volumes/DATA/03-www">
AllowOverride All
Require all granted
</Directory>
ProxyPreserveHost On
ProxyPass /ionic http://localhost:8100
ProxyPassReverse /ionic http://localhost:8100
</VirtualHost>
这里的问题是只有第一个请求 (index.html
) 被发送到离子服务器。来自此 index.html
的下一个请求将发送到 Apache,因为路径的开头不包括 /ionic
:
::1 - - [26/May/2015:21:00:31 +0200] "GET /ionic HTTP/1.1" 200 3097
::1 - - [26/May/2015:21:00:31 +0200] "GET /lib/ionic/css/ionic.css HTTP/1.1" 404 1265
::1 - - [26/May/2015:21:00:31 +0200] "GET /css/style.css HTTP/1.1" 404 1265
::1 - - [26/May/2015:21:00:31 +0200] "GET /fonts/font-awesome/css/font-awesome.min.css HTTP/1.1" 404 1265
有没有办法强制所有源自特定路径(匹配 proxypass)的请求通过代理,而无需修改 index.html
?
你有这样做的具体原因吗?因为如果没有并且您只需要在设备上检查您的应用程序,那么几乎没有其他选择。
您可以在您的设备中安装它(例如:IPhone),只要您的 phone 和开发机器(一个 运行 离子服务器)在同一网络中,你可以连接(没有电缆)
2 - Ionic View
当您想利用完整的本机功能时,您可以将您的应用程序发布到 ionic platform 并下载并安装到 Ionic View
3 - Ripple Emulator
一个 chrome 扩展,允许在浏览器中测试您的应用程序。它支持功能主义者,例如 GeoLocation
HTH
尝试在代理传递处添加斜杠,实际上在我的配置中,以下第一条规则运行良好
ProxyPass /ionic/ http://localhost:8100
在您的配置中,您可以试试这个:
<VirtualHost *:80>
ServerAdmin localhost@admin
DocumentRoot "/Volumes/DATA/03-www"
ServerName localhost
<Directory "/Volumes/DATA/03-www">
AllowOverride All
Require all granted
</Directory>
ProxyPreserveHost On
ProxyPass /ionic/ http://localhost:8100
ProxyPassReverse /ionic/ http://localhost:8100