简体   繁体   中英

Apache proxypass for Ionic Framework app

I've managed to reach internal localhost:8100 (where ionic server lives) from an external device accessing to 192.168.1.130/ionic with a proxypass. My 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>

The problem here is that only the first request ( index.html ) is made to the ionic server. Next requests comming from this index.html are made to the apache, as the path is not including /ionic at the beginning:

::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

Is there a way to force all requests that where originated from specific path (that matches proxypass) to go via proxy, without having to modify index.html ?

Do you have a specific reason to do like this ? Because if not and you only needs to check your app on a device there are few other alternatives.

1 - PhoneGap Developer app

You can install this in your device (ex: IPhone) and as long as your phone and development machine (the one running ionic server) in the same network, you could connect (with out a cable)

2 - Ionic View

When you want to leverage the full native functionality, you could publish your app to ionic platform and download in an install it to Ionic View

3 - Ripple Emulator

A chrome extension that will allow test you app in the browser. it supports functionalists such as GeoLocation

HTH

Try to add the slash at the proxy pass, actually in my configuration the following first rule works well

ProxyPass /ionic/ http://localhost:8100

In your configuration you can try this then:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM