diff --git a/http.go b/http.go
index 24c62cbc0273c586a17c1240a5e256872dda9a70..e17a97d137baab55da1728d6007f96f72b548811 100644
--- a/http.go
+++ b/http.go
@@ -282,8 +282,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	connInfo := PeerInfo{Transport: "http", RemoteAddr: r.RemoteAddr}
 	connInfo.HTTP.Version = r.Proto
 	connInfo.HTTP.Host = r.Host
-	connInfo.HTTP.Origin = r.Header.Get("Origin")
+	connInfo.HTTP.Origin = r.Header.Get("X-Real-Ip")
+	if connInfo.HTTP.Origin == "" {
+		connInfo.HTTP.Origin = r.Header.Get("X-Forwarded-For")
+	}
 	connInfo.HTTP.UserAgent = r.Header.Get("User-Agent")
+	// the headers used
+	connInfo.HTTP.Headers = r.Header
+
 	ctx := r.Context()
 	ctx = context.WithValue(ctx, peerInfoContextKey{}, connInfo)
 
diff --git a/server.go b/server.go
index 50d356066ebcdf312f5d96321cb7797af066fb44..99da30662a547d319fe3f77c7f60d5ff07a8eb1b 100644
--- a/server.go
+++ b/server.go
@@ -3,6 +3,7 @@ package jrpc
 import (
 	"context"
 	"io"
+	"net/http"
 	"sync/atomic"
 
 	"git.tuxpa.in/a/zlog/log"
@@ -141,6 +142,8 @@ type PeerInfo struct {
 		UserAgent string
 		Origin    string
 		Host      string
+
+		Headers http.Header
 	}
 }
 
diff --git a/websocket.go b/websocket.go
index 052662b6b80410294c6ab18cf9e97ea5d44a0006..76e6aee33d12c57a68d4849c5d0795a935a5c227 100644
--- a/websocket.go
+++ b/websocket.go
@@ -120,6 +120,7 @@ func wsClientHeaders(endpoint, origin string) (string, http.Header, error) {
 	header := make(http.Header)
 	if origin != "" {
 		header.Add("origin", origin)
+		header.Add("X-Forwarded-For", origin)
 	}
 	if endpointURL.User != nil {
 		b64auth := base64.StdEncoding.EncodeToString([]byte(endpointURL.User.String()))
@@ -171,14 +172,17 @@ func newWebsocketCodec(ctx context.Context, c *websocket.Conn, host string, req
 		conn:      c,
 		pingReset: make(chan struct{}, 1),
 		info: PeerInfo{
-			Transport:  "ws",
-			RemoteAddr: conn.RemoteAddr().String(),
+			Transport: "ws",
 		},
 	}
 	// Fill in connection details.
 	wc.info.HTTP.Host = host
-	wc.info.HTTP.Origin = req.Get("Origin")
+	wc.info.HTTP.Origin = req.Get("X-Real-Ip")
+	if wc.info.HTTP.Origin == "" {
+		wc.info.HTTP.Origin = req.Get("X-Forwarded-For")
+	}
 	wc.info.HTTP.UserAgent = req.Get("User-Agent")
+	wc.info.HTTP.Headers = req
 	// Start pinger.
 	go heartbeat(ctx, c, wsPingInterval)
 	return wc