Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HTTP (not HTTPS) on postwoman.io #175

Closed
NBTX opened this issue Oct 1, 2019 · 20 comments · Fixed by #200
Closed

Allow HTTP (not HTTPS) on postwoman.io #175

NBTX opened this issue Oct 1, 2019 · 20 comments · Fixed by #200
Assignees
Labels
feature New feature or request

Comments

@NBTX
Copy link
Contributor

NBTX commented Oct 1, 2019

Currently postwoman.io redirects insecure requests to HTTPS.
Whilst this is often desirable, it prevents us from testing HTTP-only sites.

So essentially, we just need to disable this redirect.

@liyasthomas
Copy link
Member

liyasthomas commented Oct 2, 2019

Browser will block any resources (scripts , link , iframe , XMLHttpRequest, fetch) to download if original html page is in https and requested resources are in http.

Browser throws an Mixed Content error.

https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content

Only work around I found is to tweak browser security policies and allow http requests.

Screen Shot 2019-10-02 at 9 29 35 AM

I'll update when I find another tweak.

@hosseinnedaee
Copy link
Contributor

Maybe we should use a proxy server. send the request to proxy server fetch HTTP request on the server and then return back the response to Postwoman client.

@liyasthomas
Copy link
Member

Proxy implementation with Nuxt middleware is planned. @hosseinnedaee would you like to work on this feature?

@hosseinnedaee
Copy link
Contributor

hosseinnedaee commented Oct 11, 2019

@liyasthomas yeah sure
do you have any idea about implementation or I just start to work on it?

@liyasthomas
Copy link
Member

liyasthomas commented Oct 11, 2019

@hosseinnedaee #2 had an active discussion around implementing middleware for proxy. This not only allow us to request for http but also solves CORS issues. NBTX is busy and couldn't follow this.

Later our team took it to telegram group chat for further discussions. Follow from this thread for discussion https://t.me/postwoman_app/72

https://blog.lichter.io/posts/nuxt-with-an-api/ this article discusses different methods for implementing middleware.

@liyasthomas liyasthomas added the feature New feature or request label Oct 11, 2019
@liyasthomas liyasthomas added this to the v1.0 Stable release milestone Oct 11, 2019
@hosseinnedaee
Copy link
Contributor

@liyasthomas Assign me to this issue.

@frankli0324
Copy link

websocket support on this?

@liyasthomas
Copy link
Member

@NBTX is working on proxy mode for WebSocket.

@frankli0324
Copy link

need help?

@liyasthomas
Copy link
Member

@frankli0324 we would love to have this feature implemented. do contribute.

@frankli0324
Copy link

will take a look next week... got some schedules this weekend

@hoppscotch hoppscotch deleted a comment from interfacekun Apr 20, 2020
@hoppscotch hoppscotch deleted a comment from diekotto Apr 20, 2020
@frankli0324
Copy link

frankli0324 commented Apr 28, 2020

what I've done so far:

I tried to create a single nginx server configuration for anyone who wants to build up their own proxy server installing as less things as possible:

server {
	server_name your_own_doman;
	listen 443 ssl;
	include /etc/nginx/conf.d/ssl; # certificate, key
	resolver 8.8.8.8;
	location / {
		if ( $arg_target = '' ) { return 403 'null target'; }
		if ( $arg_scheme = '' ) { set $arg_scheme 'http'; }
		if ( $arg_scheme = 'ws' ) { set $arg_scheme 'http'; }
		if ( $arg_scheme = 'wss' ) { set $arg_scheme 'https'; }
		if ( $arg_scheme = 'http' ) { set $port '80'; }
		if ( $arg_scheme = 'https' ) { set $port '443'; }
		if ( $arg_port != '' ) { set $port $arg_port; }
		set $query '';
		set $path '';
		rewrite_by_lua_block { # on debian/ubuntu: libnginx-mod-http-lua
        	ngx.var.query = ngx.unescape_uri(ngx.var.arg_query)
			ngx.var.path = ngx.unescape_uri(ngx.var.arg_path)
        }
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass $arg_scheme://$arg_target:$port$path?$query;
	}
}

and made a little change

diff --git a/components/realtime/websocket.vue b/components/realtime/websocket.vue
index fba150e..9c7e56c 100644
--- a/components/realtime/websocket.vue
+++ b/components/realtime/websocket.vue
@@ -103,7 +101,19 @@ export default {
         },
       ]
       try {
-        this.socket = new WebSocket(this.url)
+        if (this.$store.state.postwoman.settings.PROXY_ENABLED) {
+          const original = new URL(this.url);
+          const proxy = new URL("your_proxy_server");
+          let proto = original.protocol;
+          proxy.searchParams.append("scheme", proto.substr(0, proto.length-1));
+          proxy.searchParams.append("target", original.hostname);
+          proxy.searchParams.append("port", original.port);
+          proxy.searchParams.append("path", original.pathname);
+          proxy.searchParams.append("query", original.searchParams.toString());
+          this.socket = new WebSocket(proxy);
+        }
+        else
+          this.socket = new WebSocket(this.url)
         this.socket.onopen = event => {
           this.connectionState = true
           this.communication.log = [

still trying to adopt the original version of http proxy server so we could use a single proxy for both types of requests

@frankli0324
Copy link

frankli0324 commented Apr 28, 2020

demo: https://proxy.frankli.site
btw the original proxy is down

@fzyzcjy
Copy link

fzyzcjy commented Jul 8, 2020

Any progress? When developing it is very common to deploy on localhost with HTTP not HTTPS. Thus this feature is very desired and will be commonly used.

Thanks!

p.s. @franeli0324's site seems to be down.

@liyasthomas
Copy link
Member

For localhost endpoints, you should install Browser Extension (link in readme). For other non-https endpoints turn-on Proxy from Settings> Proxy.

*The latest Chrome extension is having a minor bug which has been fixed but is currently under review. Kindly use another browser (Firefox) local endpoints.

@fzyzcjy
Copy link

fzyzcjy commented Jul 8, 2020

Thanks! I just searched the plugin but find it 404, so I will turn to firefox or wait

@liyasthomas
Copy link
Member

Buggy version has been taken down - use Firefox / Proxy mode.

@fzyzcjy
Copy link

fzyzcjy commented Jul 8, 2020

OK thanks!

By the way I find another solution: Disable Chrome's security check for this particular webpage in chrome's setting.

@idling-mind
Copy link

I'm trying to access an internal http host. Couldnt get it working in anyway. Any suggestions?

@liyasthomas
Copy link
Member

@idling-mind turn on Proxy Mode from Settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants