假设客户端 A 通过 TCP/IP 套接字连接到服务器 B 是否可以创建一个类似于服务器的代理来执行此操作:
客户端 A 连接到代理 X ;并尝试向服务器进行身份验证(发送身份验证数据);代理 X 接收这些数据并将它们发送到服务器 B 并从服务器 B 获取响应并将结果返回给客户端 A
是否可以?如果有任何可用的源代码?
我在 nginx 中为 node.js 服务器设置了一个反向代理。
server {
listen 80;
server_name sub.domain.tld;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Run Code Online (Sandbox Code Playgroud)
它的工作原理都非常愉快,不过,我只是想sub.domain.tld继续工作。domain.tld在浏览器中打开 仍然路由到 node.js 服务器。
我正在尝试设置从apache到IIS 7服务器的反向代理。
我已经设置了非常基本的代理规则。
<VirtualHost *:443>
ServerName MY_APPACHE_SERVER_NAME
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/ssl/certs/...
SSLCertificateKeyFile /etc/ssl/private/...
SSLCertificateChainFile /etc/ssl/certs/...
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
ProxyPreserveHost On
ProxyPass / https://MY_IIS_SERVER_NAME/
ProxyPassReverse / https://MY_IIS_SERVER_NAME/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
如果我通过代理访问主页,则会收到404错误。
在IIS服务器端,在C:\ Windows \ System32 \ LogFiles \ HTTPERR \ httperr.log文件中,我可以看到传入呼叫并将响应设置为404
2015-03-27 15:07:36 184.73.82.33 42313 10.79.154.81 443 HTTP/1.1 GET / 404 - NotFound -
2015-03-27 15:07:52 184.73.82.33 42314 10.79.154.81 443 HTTP/1.1 GET / 404 - NotFound -
Run Code Online (Sandbox Code Playgroud)
在http响应上,我可以看到响应来自IIS服务器服务器:Microsoft-HTTPAPI / 2.0
HTTP/1.1 404 Not Found
Date: Fri, 27 Mar 2015 15:07:52 …Run Code Online (Sandbox Code Playgroud) 我正在为马丁尼应用程序编写测试代码,在go中作为反向代理工作,并希望使用它进行测试httptest.ResponseRecorder,但是我得到了以下错误.
[martini] PANIC: interface conversion: *httptest.ResponseRecorder is not http.CloseNotifier: missing method CloseNotify
Run Code Online (Sandbox Code Playgroud)
httptest.ResponseRecorder 没办法 CloseNotify()
我该怎么测试呢?
package main
import (
"github.com/go-martini/martini"
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"net/http/httputil"
"net/url"
"testing"
)
func TestReverseProxy(t *testing.T) {
// Mock backend
backendResponse := "I am the backend"
backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(backendResponse))
}))
defer backend.Close()
backendURL, _ := url.Parse(backend.URL)
// Frontend
m := martini.Classic()
m.Get("/", func(w http.ResponseWriter, r *http.Request) {
proxy := httputil.NewSingleHostReverseProxy(backendURL)
proxy.ServeHTTP(w, r)
})
// Testing
req, _ := …Run Code Online (Sandbox Code Playgroud) 我正在尝试使apache服务器成为我的节点服务器的网关.
我的apache将提供静态页面,节点将充当rest api服务器.
节点和apache都位于同一台服务器上,ubuntu 64bit ec2.
我试图为https做这个并且失败了,后来我试图为代理传递打开一个http端口并且它工作了(我已经将节点更改为http以使其工作).
我的最后一招将是将节点转换为Web服务器,但我希望保持简单,因为它很快就会重构并使用meteor.
我会感激任何建议
这是我对apache的配置
<VirtualHost *:443>
ServerName secure.mysite.co.il
ServerAdmin admin@mysite.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /ssl/mysite.crt
SSLCertificateKeyFile /ssl/mysite.key
SSLCertificateChainFile /ssl/ca-bundle-client.crt
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /echo/test https://127.0.0.1:8001/echo/test
ProxyPassReverse /echo/test https://127.0.0.1:8001/echo/test
Run Code Online (Sandbox Code Playgroud)
成功的http配置
<VirtualHost *:80>
ServerAdmin admin@mysite.com
ServerName mysite.co.il
ServerAlias www.mysite.co.il
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud) 我有一个不应直接访问的 Couchdb 数据库,因此我需要使用反向代理。如何将 Nginx 或 apache 配置为 Couchdb 的反向代理?
我想https在ubuntu / centos的Docker容器上使用Nginx 设置反向代理。在浏览器方面,我遇到了connection refused错误。而且,我在/var/log/nginx/access.log或下看不到任何东西/var/log/nginx/error.log。
我能够http再次在Docker容器上使用Nginx 设置反向代理。并且,还可以https在普通的ubuntu和centos虚拟机上使用Nginx进行反向代理。
能理解为什么httpsdocker容器上的nginx反向代理无法从浏览器连接的原因吗?
如果需要任何其他信息,我可以为您提供。提前致谢。
作为参考,请检查此sites-available/default文件。
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location ~* /rabbitmq/(.*) {
rewrite ^\/rabbitmq\/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:15672;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header …Run Code Online (Sandbox Code Playgroud) 因为SEO我设置了一个工作正常的反向代理:
设置如下:
1) http://www.example.com(node.js托管在heroku)
2) http://blog.example.com(在godaddy托管的wordpress)
3)访问http://www.example.com/blog的访问者从http://blog.example.com获取内容.
这工作正常,1)我也有代理使用流行的nodejitsu htt-proxy和httpProxyRules模块:
// Set up proxy rules instance
var proxyRules = new httpProxyRules({
rules: {
'.*/blog': 'https://blog.example.com', // Rule (1)
},
default: 'https://www.example.com' // default target
});
// Create reverse proxy instance
var proxy = httpProxy.createProxy();
// Create http server that leverages reverse proxy instance
// and proxy rules to proxy requests to different targets
http.createServer(function(req, res) {
// a match method is exposed on the …Run Code Online (Sandbox Code Playgroud) 我是 Nginx 的新手,我的目标是什么?
当我访问127.0.0.1:8080/proxy/git/or 时Https://127.0.0.1/proxy/git/,Nginx(反向)代理可以访问https://github.com
我的 nginx conf 很糟糕:
http {
server {
listen 8080 default backlog=2048;
listen 443 ssl;
server_name 127.0.0.1;
ssl_certificate /etc/nginx/xxxxxxx.crt;
ssl_certificate_key /etc/nginx/xxxxxxx.key;
location /proxy/git/ {
proxy_pass https://github.com/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
}
error_page 500 502 503 504 /50x.html;
}
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size …Run Code Online (Sandbox Code Playgroud) 我一直在使用代理服务。现在,我需要删除。我忘记了如何将代理添加到wget。有人可以帮我回到不使用代理的普通wget上。截至目前,我正在使用
wget <link> --proxy=none
Run Code Online (Sandbox Code Playgroud)
但是当我使用预先编写的脚本进行安装时遇到了问题。遍历所有脚本并更改每个命令非常费力。任何更简单的解决方案将不胜感激。
谢谢