如果可能的话,我希望避免向外界开放默认端口 3306。我们运行 Nginx 用于其他应用程序的反向代理目的。这里的目标是使用 MySQL Workbench 等客户端以安全的方式从本地网络外部访问 MySQL 数据库。MySQL 服务器在 Debian (Linux) 虚拟机上运行。
我配置了一个服务器块,如下所述。在 MySQL Workbench 中使用非 root 用户连接到 mysql.domain.com 端口 80 会导致失败。
服务器块:
server {
server_name mysql.domain.com;
location / {
proxy_pass http://localhost:3306/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
Failed to Connect to MySQL at mysql.domain.com:80 with user non-root.
Lost connection to MySQL at 'waiting for initial communication packet', system error: 10060
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 nginx 构建一个反向代理,以使我的项目中的所有内容都可以从单个地址访问。对于单个服务,以下配置可以正常工作
/etc/nginx/sites-enabled/reverse-proxy.conf
server {
listen 80;
listen [::]:80;
location / {
resolver 127.0.0.1;
allow "x.x.x.x";
deny all;
proxy_pass http://consul:8500;
}
}
Run Code Online (Sandbox Code Playgroud)
因此,当我在浏览器中调用服务器的 ip 时,x.x.x.x我会看到 Consul UI 和显示 的 URL x.x.x.x/ui/dc1。除此之外,我看到 UI 成功请求了资产文件。
我的问题; 是否有可能在同一台服务器上托管两个不同的服务并仅在不同的位置引用它们?例如,如果我想包含 Vault UI,那么我会考虑这样做:
server {
listen 80;
listen [::]:80;
location /consul {
resolver 127.0.0.1;
allow "x.x.x.x";
deny all;
proxy_pass http://consul:8500;
}
location /vault {
resolver 127.0.0.1;
allow "x.x.x.x";
deny all;
proxy_pass http://vault:8200;
}
}
Run Code Online (Sandbox Code Playgroud)
但是我不确定是否可以通过这种方式完成。我得到的最远的结果是打开Consul UI,但未找到所有其他子请求(即加载资产)。
更新
我认为我的问题是我错误地使用location和proxy_pass
观察第一个配置(正在运行) …
哪个IIS 7 ISAPI筛选器可以帮助我这样做:
http://site1.domain1.com:80 ==>内部IIS服务器1(HTTP,TCP 80)
https://site2.domain1.com:443 ==>内部IIS服务器1(HTTPS,TCP 443)
http://site1.domain2.com:80 ==>内部IIS服务器2(HTTP,TCP 80)
http://site2.domain2.com:443 ==>内部IIS服务器2(HTTPS,TCP 443)
http://site1.domain3.com:80 ==>内部IIS服务器2(HTTP,TCP 8080)
http://site2.domain3.com:443 ==>内部IIS服务器2(HTTPS,TCP 8443)
我们目前正在设计一个在WebSeal反向代理后面作为.Net Web应用程序运行的解决方案.
我在网上看到了一些评论,人们对此有各种各样的问题,例如重写viewstate.
问题是:有没有人实施这种技术组合并让它发挥作用?
CDN很棒,但我发现需要动态地将文件填充到一个文件中.下面我将介绍如何设置NGINX来执行此操作.我的问题是Is it any slower or are there any performance issues for doing a proxy_pass to a resource than hitting the resource directly?例如.. proxy_pass通过URL到http://domain.com/file.jpg与直接加载http://domain.com/file.jpg.还有,are you saving any server server resources by doing a proxy_pass to another image location vs simply serving up the image?
我设置了一个Nginx服务器,因此对http://domain.com/image/XYP.jpg的请求会对CDN进行Proxy_pass,有效加载http://cdn.com/XYP.jpg.我配置Nginx来检查是否有错误代码,然后做其他事情.IF(错误页面)404,nginx可以将您传递给本地资源,然后可能会触发在CDN上创建文件.
下次,您要求http://domain.com/image/XYP.jpg,您将访问CDN.
xyz.jpgxyz.jpgCDN上的触发文件生成xyz.jpg我想知道是否存在类似私有ESI片段的东西.在我读到的文档中:
我不完全理解我是否能够或不能按用户缓存页面的某些部分.有人可以解释一下吗?
提前致谢!
我有一些Web服务器正在运行,我希望所有这些服务器都可以通过一个域访问.我在IIS中将ARR设置为另一台服务器中的反向代理,它工作正常.但是,当请求被重定向到服务器时,我需要保留源IP地址.否则,服务器会看到所有连接都来自localhost,这不是很好.
我知道有一个选项forwarded_for可以创建X-Forwarded-For标头,但它不是真的透明,因为我有WAF(Web应用程序防火墙)问题.
我目前正在撰写GoLang网站,并希望尽快添加SSL.我的问题是使用内置的Golang SSL软件包有哪些优点/缺点,或者当我将它用于反向代理时,我应该/我可以用nginx做SSL吗?
我用自己的ReverseProxy做了一些麻烦我用Go写的.我想将我的Golang-Webserver与我的Apache Webserver连接起来.我的Apache Web服务器也应该在https和反向代理上运行.所以我写了下面的代码,但我总是得到错误:代理错误:x509:由未知权限签署的证书.那么apache必须使用与apache相同的证书或者问题是什么?这里有一些代码片段,但我认为它没有ssl证书的问题一切正常:(
func (p *Proxy) directorApache(req *http.Request) {
mainServer := fmt.Sprintf("%s:%d", Config.HostMain, Config.PortMain)
req.URL.Scheme = "https"
req.URL.Host = mainServer
}
func (p *Proxy) directorGo(req *http.Request) {
goServer := fmt.Sprintf("%s:%d", Config.GoHost, Config.GoPort)
req.URL.Scheme = "http"
req.URL.Host = goServer
}
func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
fmt.Println(req.URL.Path)
if p.isGoRequest(req) {
fmt.Println("GO")
p.goProxy.ServeHTTP(rw, req)
return
}
p.httpProxy.ServeHTTP(rw, req)
}
func main() {
var configPath = flag.String("conf", "./configReverse.json", "Path to the Json config file.")
flag.Parse()
proxy := New(*configPath)
cert, err := …Run Code Online (Sandbox Code Playgroud) 我在服务器配置上遇到问题,我无法弄清楚我做错了什么.
所以我有一个像这样的nginx代理:
server {
listen *:443 ssl;
ssl_certificate /root/software/keys/mywebsite.keys/mywebsite.crt;
ssl_certificate_key /root/software/keys/mywebsite.keys/mywebsite.key;
server_name www.mywebsite.com mywebsite.com;
access_log /var/log/nginx/mywebsite.access.log;
error_log /var/log/nginx/mywebsite.error.log;
root /srv/new-website;
index index.html index.htm index.php;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://127.0.0.1:8082;
}
}
Run Code Online (Sandbox Code Playgroud)
我的容器正在我的docker-compose.yml文件中侦听端口8082:
version: '2'
services:
websites:
build:
context: ./dockerfiles/
args:
MYSQL_ROOT_PASSWORD: MyPassword
volumes:
- ./logs:/var/log
- ./html:/var/www
- ./mysql-data:/var/lib/mysql
ports:
- "8082:80"
Run Code Online (Sandbox Code Playgroud)
在我的容器内,我正在安装nginx,使用此配置:
server { …Run Code Online (Sandbox Code Playgroud)