How could I set a reverse proxy with caddy that speak with a crossbar router?
I have a docker with a crossbar router that listen on localhost 8080, and I use caddy as a reverse proxy.
Below the Caddyfile:
`0.0.0.0:80
proxy /ws localhost:8080{
proxy_header Connection {>Connection}
proxy_heade Upgrade {>Upgrade}
}
header /ws {
Upgrade "WebSoket"
Connection "Upgrade"
}`
'tcpflow 8080' return nothing when I try to connect.
Below the header from chrome:
RESPONSE
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-Websocket-Accept: r/PdCQJibmcb5XrfVbnSXJMuf9g=
Sec-Websocket-Protocol: wamp.2.json
Server: Caddy
Server: Crossbar/0.11.1
Upgrade: WebSocket
X-Powered-By: AutobahnPython/0.10.9
Date: Tue, 09 Feb 2016 14:12:04 GMT
REQUEST
GET ws://78.46.244.23/ws HTTP/1.1
Host: 78.46.244.23
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: chrome://newtab
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTM
like Gecko) Chrome/48.0.2564.103 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Sec-WebSocket-Key: OaEUxWnqjZWyfLypeYxeXw==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: wamp.2.json
Below the frame:
[1,"realm1",{"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"progressive_call_results":true}},"publisher":{"features":{"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"publisher_identification":true}},"subscriber":{"features":{"publisher_identification":true}}}}]
And the console error:
WebSocket connection to 'ws://78.46.244.23/ws' failed: Invalid frame header
you have a typo in your Caddyfile:
Upgrade "WebSoket"
Related
I've been working on this issue for two days. If I create a new project following the tutorial here, and run it through IIS Express, it works fine. As soon as I switch it to IIS, it fails.
So, when hosted in Express I send:
OPTIONS http://localhost:63274/api/test HTTP/1.1
Host: localhost:63274
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Request-Method: PUT
Origin: http://localhost:4001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
DNT: 1
Accept: */*
Referer: http://localhost:4001/admin/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-CA,en;q=0.9,fr;q=0.8
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: PUT
X-SourceFiles: =?UTF-8?B?RDpcSGVicmFcTWluZGZsYXllclxNaW5kZmxheWVyXGFwaVx0ZXN0?=
X-Powered-By: ASP.NET
Date: Wed, 24 Jul 2019 15:45:48 GMT
Content-Length: 0
And after the preflight:
PUT http://localhost:63274/api/test HTTP/1.1
Host: localhost:63274
Connection: keep-alive
Content-Length: 0
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:4001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
DNT: 1
Accept: */*
Referer: http://localhost:4001/admin/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-CA,en;q=0.9,fr;q=0.8
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 17
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
X-SourceFiles: =?UTF-8?B?RDpcSGVicmFcTWluZGZsYXllclxNaW5kZmxheWVyXGFwaVx0ZXN0?=
X-Powered-By: ASP.NET
Date: Wed, 24 Jul 2019 15:45:48 GMT
PUT: Test message
And when hosted from IIS I send (an identical request of):
OPTIONS http://localhost:4013/api/test HTTP/1.1
Host: localhost:4013
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Request-Method: PUT
Origin: http://localhost:4001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
DNT: 1
Accept: */*
Referer: http://localhost:4001/admin/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-CA,en;q=0.9,fr;q=0.8
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: PUT
Date: Wed, 24 Jul 2019 15:50:34 GMT
Content-Length: 0
And after the preflight:
PUT http://localhost:4013/api/test HTTP/1.1
Host: localhost:4013
Connection: keep-alive
Content-Length: 0
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:4001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
DNT: 1
Accept: */*
Referer: http://localhost:4001/admin/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-CA,en;q=0.9,fr;q=0.8
HTTP/1.1 405 Method Not Allowed
Cache-Control: private
Allow: GET, HEAD, OPTIONS, TRACE
Content-Type: text/html; charset=utf-8
Server: Monsters/4.0
Date: Wed, 24 Jul 2019 15:47:58 GMT
Content-Length: 5298
... standard iis 500 page content...
The OPTIONS request and response from both is practially identical; the only change is the host (port) and timestamps. However, after the preflight, when hosted in IIS it responds with 405 Method Not Allowed and a different header Allow: GET, HEAD, OPTIONS, TRACE.
Is there something I need to add to the web.config for IIS specifically?
I'm just using the Chrome devtools to create an XMLHttpRequest for testing.
I have already removed WebDav from IIS.
The web.config is setup exactly as it would be from the linked tutorial.
I am running Windows 10 and IIS 10.
The only module I have installed is URL Rewrite, but no rules are enabled (and it is not configured in the web.config).
Thanks in advance for any hints as to what is going wrong.
I uninstalled WebDav then rebooted.
It's working.
...
Kill me.
I am writing a very basic websocket server. This works in Google Chrome but not in Firefox (v46.0.1). The error message in Firefox is not very helpful either.
Firefox can't establish a connection to the server at
ws://localhost:9000/.
This is the Opening handshake from firefox.
GET / HTTP/1.1
Host: localhost:9000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Sec-WebSocket-Version: 13
Origin: null
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: ZfChFbbco7cR0jrAliH+LQ==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
This is my server's opening handshake response.
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Accept: <accept-key>
Is the server's opening response not enough for Firefox?
I do an AJAX POST to my webservice, and it sets 2 cookies in the response, but Chrome does not set them. Safari and Firefox do, however.
Here's the request:
POST /api/login HTTP/1.1
Host: 0.0.0.0:8080
Connection: keep-alive
Content-Length: 50
accept: application/json
Origin: http://0.0.0.0:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
content-type: application/json
Referer: http://0.0.0.0:8080/form
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,nl;q=0.6,de;q=0.4,fr;q=0.2,pl;q=0.2
Response:
HTTP/1.1 200 OK
X-Powered-By: Express
Vary: X-HTTP-Method-Override, Accept-Encoding
x-frame-options: sameorigin
set-cookie: keystone.uid=s%3A55efe88923f753865f7a0985%3Ac5aT64aih9lxXi%2BNiSMr1rUJW4kzWyyNUforvUOrckk.JovuV%2FqeoQ32PiuyNPAZ7JcbIxXBcBvj%2FWFp8vf3SQQ; Path=/; HttpOnly
set-cookie: keystone.sid=s%3ADcv5el-TjLRkOSH9vNbvxQoOai-SQj-3.ZTfPFwEZp5mdVHSDZTukO%2FnrDnSpGU3OMW3tQu%2FSz7U; Path=/; HttpOnly
Content-Type: application/json; charset=utf-8
Content-Length: 224
ETag: W/"e0-B6OeRPdDEP0WPVdlZHqarA"
Date: Fri, 06 Nov 2015 14:39:37 GMT
Connection: keep-alive
I'm out of ideas. This doesn't work with a fully qualified domain name on port 80 either.
Found the solution:
You have send the request with credentials (XMLHttpRequest.withCredentials or e.g. credentials: 'include' for whatwg fetch).
Even though this is pointless since you're logging in and don't have any/have invalid cookies, it makes Chrome store the cookies from the returned answer. ¯\_(ツ)_/¯
As pointed out by #Anne, the XMLHTTPRequest specification actually requires user agents to disregard returned cookies unless withCredentials is specified. http://www.w3.org/TR/XMLHttpRequest/#the-withcredentials-attribute
I have a Java program which forwards the HTTP request from clients to INTERNET and write back the response to client. But when clients trying Google.com from their browser i am getting 302 found Response from Internet.
Here is the Request from client :
GET http://google.com/ HTTP/1.1
Host: google.com
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 OPR/28.0.1750.51
DNT: 1
Accept-Encoding: gzip, deflate, lzma, sdch
Accept-Language: en-US,en;q=0.8
Cookie: PREF=ID=0168c274e46046ff:FF=0:LD=en:TM=1427909641:LM=1428321915:GM=1:S=HGTpo1ahuPUd4Nu2; SID=DQAAAPgAAACOH1NUVCRnVJfjL-W4MtbTmqx9yY1Wbra4LM7D8_uslXU_43zD4QrZl4eHqBuukNoKFw0gD68Vt7DltSgBrOoVRufDgeLImP8321g2-IxjmtqwjJoI9sSM3YEwC5ZvnTNyrwuHhBp-zZqImsaHshVmvt8GEV1WDFHs4OZ74g219CeKYztHKjsQLDS_yZ725qsIKWjvbb_NlnO5IqktZ0Q6JXIMRPzshZQvoq7ZiwH9RfiIASpHIiFC1XDwrMZDcbONpKCke2QxZtmxSPfUHXuBx53bJOZFHUrcAJAvihBAXoFwZHUr2beVtRuLe1w8blbt6AGTy9dT9gZ9nVjeSHzK; HSID=Aso16-EnwP4siCr5Q; APISID=DIHL_mSdprkZSELD/AjGWXXsjCWUT9FEuy; NID=67=DGyWJrkoHYqgDmpEMmQVlnzZQLlwGNTxbAZ8--PQeTPlZ4SbL3AbFNP40h0NOI3ztb_6SkDTHwGJonmESsToDR6Vkmur0VST-6k34xVvQM9FQH_PaoMrK8O6kT0Avd8FIITl7G7ERJbvbwWIsCuhIwZOR2cj2r6aCmnM27A
This is the Response i got :
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.co.in/?gfe_rd=cr&ei=Uhw7Vbe6H_PI8Ae_qICIBA
Content-Length: 261
Date: Sat, 25 Apr 2015 04:47:14 GMT
Server: GFE/2.0
Alternate-Protocol: 80:quic,p=1
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
here.
</BODY></HTML>
Is this because Google using HTTPS instead of HTTP. and it is trying to redirect the request...?
But how i should process this reply?
I send the same response to client. But no redirection is happening,
What should i do?
From the Location header in the Http Response, seems that Google detected that the call came from India and it's redirecting the call to Google India i.e. http://www.google.co.in/?gfe_rd=cr&ei=Uhw7Vbe6H_PI8Ae_qICIBA.
When you get a 302 response your client should react properly and follow the call to the Location header.
Sometimes it is an issue about ipv6 transaction against ipv4.
Try disable ipv6 in your server and reboot with:
echo net.ipv6.conf.all.disable_ipv6=1 > /etc/sysctl.d/disableipv6.conf
I've implemented a web application that takes advantage of CORS to gather JSON data from another server. The servers run on different subdomains. Everything seems implemented correctly, and it works fine with Chromium. Below is a copy of my requests, from Chromium.
My problem is that in Firefox (tested with 13.0.1), no request is ever made for my AJAX resource. No preflight request is ever sent, and no actual request is made. Instead, I get this error, from the XMLHttpRequest.send() function:
[21:40:27.546] uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://192.168.1.99:2502/static/mootools-core-1.4.5.js Line: 5398"]
I am using Mootools' Request.JSON object, which sets various extra headers, meaning that a preflight would indeed be required. However, it is never sent.
Unfortunately, JSONP is not an option, as the data is sensitive.
Does anyone have insight into what the problem could be?
Thanks very much.
Working example, from Chromium:
Preflight request:
OPTIONS /api/resource HTTP/1.1
Host: dev0.mydomain.com
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://192.168.1.99:2502
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19
Access-Control-Request-Headers: origin, x-request, x-requested-with, accept
Accept: */*
Referer: http://192.168.1.99:2502/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: [redacted]
Preflight response:
HTTP/1.0 200 OK
Server: PasteWSGIServer/0.5 Python/2.7.3
Date: Fri, 29 Jun 2012 01:43:37 GMT
Content-Length: 0
Access-Control-Allow-Headers: Cookie, Origin, X-Request, X-Requested-With, Accept
Access-Control-Max-Age: 1
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://192.168.1.99:2502
Access-Control-Allow-Methods: GET
Content-Type: text/html; charset=UTF-8
"Real" request:
GET /api/resource HTTP/1.1
Host: dev0.mydomain.com
Connection: keep-alive
Origin: http://192.168.1.99:2502
X-Request: JSON
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19
Accept: application/json
Referer: http://192.168.1.99:2502/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: [redacted]
"Real" response:
HTTP/1.0 200 OK
Server: PasteWSGIServer/0.5 Python/2.7.3
Date: Fri, 29 Jun 2012 01:43:37 GMT
Access-Control-Allow-Origin: http://192.168.1.99:2502
Content-Type: text/html; charset=UTF-8
Content-Length: 22
Access-Control-Allow-Credentials: true
The answer is given in the comments to the question. Firefox was not sending the request due to the HTTP authentication username I had provided.