ashumeow / pcaphar

Automatically exported from code.google.com/p/pcaphar
Apache License 2.0
0 stars 0 forks source link

Feature Request: Allow configuration of URL path in 1 place #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The application currently always runs at / when run using Google AppEngine. 
Modifying the app.yaml file will allow you to modify where the server is 
looking for files, but the application itself has a large number of hardcoded 
paths. The feature request in it's simplest form would be to convert all links 
within the application to be relative. The more advanced version would be to 
also provide a single place to specify the root path for the application to run 
at instead of having the user edit the app.yaml file.

Use case:

I want to run pcap2har behind a proxy which converts from hostname:port/ to 
hostname/pcap2har/. Proxying from / to /pcap2har/ is extremely difficult even 
with HTML rewrite enabled. Having the application use relative links and a 
configurable base path would make this much easier.

Original issue reported on code.google.com by bberenb...@gmail.com on 13 Dec 2012 at 11:48

GoogleCodeExporter commented 9 years ago
Thank you for using pcaphar. However, I don't think I understand your request. 
What are the problems do you have when proxying? How do you config you proxy?

Original comment by ls...@google.com on 14 Dec 2012 at 8:59

GoogleCodeExporter commented 9 years ago
I run pcaphar using the dev version of google app engine. The exact command I 
use is: screen -d -m dev_appserver.py --port=8081 --address=172.28.4.52 src/ 
This binds to an internal IP and port 8081 of my network. The machine where 
pcaphar is running also runs other http services on other non standard ports.

To deal with this I have Apache running a reverse proxy on port 80. I would 
like to have http://hostname/pcap2har/ reverse proxied to http://hostname:8081/

To do this without changing anything inside of pcaphar, I would need to rewrite 
every url and resource on the fly using mod_proxy_html. This is the httpd 
configuration I tried to use to do this: http://pastebin.com/2eAeypX9 but it 
did not work consistently. The harviewer portion required multiple page reloads 
to load a complete waterfall with css etc.

If I could run pcaphar at http://hostname:8081/pcap2har/ then proxying it to be 
at http://hostname/pcap2har would be much easier.

To do this, I tried to modify the app.yaml file like so: 
http://pastebin.com/LjWgYbT2

However this will still not work, and requires further modification of the 
pcaphar.py file. At that point, it becomes extremely difficult to manage. 
Especially if this software package is ever updated. 

Original comment by bberenb...@gmail.com on 14 Dec 2012 at 10:13

GoogleCodeExporter commented 9 years ago
Just wanted to check in to see if my explanation made sense or if you need more 
information.

Original comment by bberenb...@gmail.com on 15 Jan 2013 at 10:54

GoogleCodeExporter commented 9 years ago
Thanks for the following up. I have tried myself for proxying and am working on 
a fix to make it easy for proxying. I have a working prototype now, will update 
when it is ready.

Original comment by ls...@google.com on 16 Jan 2013 at 1:35

GoogleCodeExporter commented 9 years ago
Thanks for digging further into it. I am really excited to see this get fixed!

Original comment by bberenb...@gmail.com on 4 Feb 2013 at 7:56

GoogleCodeExporter commented 9 years ago
I will be updating the source code with this week. Thanks for your patience. I 
have working version of proxy for testing at http://a.instwave.com/pcap2har/. 
Let me know if you encounter any problems. 

Original comment by ls...@google.com on 4 Feb 2013 at 8:49

GoogleCodeExporter commented 9 years ago
Tested it with some basic content and it worked without issue. Thanks much! 
Looking forward to the new commit.

Original comment by bberenb...@gmail.com on 8 Feb 2013 at 12:28

GoogleCodeExporter commented 9 years ago
Checked code in as of r59.

Original comment by ls...@google.com on 8 Feb 2013 at 7:28

GoogleCodeExporter commented 9 years ago
I set this up, and it works fine as long as I proxy hostname:8081/ to 
hostname:80/

But hostname:8081/ to hostname:80/pcap2har does not work after submitting the 
har file.  It redirects to hostname:80/view?hash_str=HASH

Could you please share the proxy configuration you use in the 
http://a.instwave.com/pcap2har/ example?

Original comment by bberenb...@gmail.com on 12 Feb 2013 at 1:20

GoogleCodeExporter commented 9 years ago
I just wanted to follow up on this to see if you would be willing to share your 
proxy config.

Original comment by bberenb...@gmail.com on 8 Aug 2013 at 10:50

GoogleCodeExporter commented 9 years ago
Sorry for the late reply, I have to dig up to foudn the config. Here it is:
        RewriteEngine on
        RewriteRule ^/pcap2har$ /pcap2har/ [R]

        ProxyRequests Off
        ProxyPass /pcap2har/ http://pcapperf.appspot.com/
        ProxyPassReverse /pcap2har/ http://pcapperf.appspot.com/

This is just for my test, so the whole config is very simple. I copy and paste 
it here for your reference:
$ cat /etc/apache2/sites-enabled/001-proxy 
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www

        RewriteEngine on
        RewriteRule ^/pcap2har$ /pcap2har/ [R]

        ProxyRequests Off
        ProxyPass /pcap2har/ http://pcapperf.appspot.com/
        ProxyPassReverse /pcap2har/ http://pcapperf.appspot.com/

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    #LogLevel debug

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Original comment by ls...@google.com on 12 Aug 2013 at 1:59