最近,我发现我的网站运行速度越来越慢。我发现我的服务器上有 8GB Apache 日志(我在 Debian 6 服务器上运行 Play!Framework Web 应用程序),并且带宽完全超载。对于一个每天浏览量很少的小型个人网站来说,这完全是疯狂的。
经过调查和收集一些信息后,我发现了我的错误:在我的 Apache 配置中,我取消了“ProxyRequests On”行的注释,因此我的服务器可以免费用作世界上每个人的免费代理。真丢脸。
至少在那段时间,我调整了防火墙以限制并发连接,并为 Apache2 安装了 mod_qos。
但是,现在所有传入请求都将重定向到我的 Web 应用程序,无论域名是什么,而不是像良好的免费代理那样将请求重定向到目的地。例如,如果有人使用我的服务器,认为它仍然是一个有效的代理,在雅虎上搜索“年轻的裸体儿童”,他就会访问我的网站。我想现在你明白我的意思了。
那么,如果将“ http://yahoo.com/whatever ”的请求发送到我的服务器,我应该怎么做,该请求就会被拒绝?
这是我当前的配置:
在/etc/init.d/apache2/sites-available/mysite.fr中:
ProxyRequests Off
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.fr
ServerAlias *.mysite.fr
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:9000/ retry=0
ProxyPassReverse / http://127.0.0.1:9000
# Uncomment the line below if your site uses SSL.
#SSLProxyEngine On
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)在/etc/init.d/apache2/mods-available/proxy.conf中:
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
Run Code Online (Sandbox Code Playgroud)我设法使用此 Etherpad 安装说明启动并运行 Etherpad 。
它在我的服务器上运行http://localhost:9000/,并通过反向代理和 SSL 在 Apache 上交付到https://www.example.com/.
这一切都运行良好,但由于 Etherpad 不是我唯一的应用程序,我希望通过https://www.example.com/etherpad/. 我该如何处理这个问题?
我尝试将ProxyPass命令更改为
ProxyPass /etherpad/ http://localhost:9000/
ProxyPassReverse /etherpad/ http://localhost:9000/
Run Code Online (Sandbox Code Playgroud)
这使得它可以在目录中使用,但其中的所有资源仍然从(根目录)/etherpad/传递。/在/etc/etherpad/etherpad.local.properties配置文件中我没有找到任何相关设置。
我如何告诉 Etherpad 位于子目录中?我无法使用另一个子域,因为那里没有 SSL。
我有和的NodeJS Nginx的运行我是API“API_KEY”在增派头及其在没有收到req.headers并req.get('api_key')在我的NodeJS有nginx的波纹管配置文件
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name mysite.com;
return 301 https://$host$request_uri;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:9102/;
proxy_set_header Host $http_host;
proxy_set_header api_key $http_api_key;
#proxy_set_header api_key 'Some Value'; works
proxy_redirect off;
}
}
Run Code Online (Sandbox Code Playgroud)
如果设置proxy_set_header api_key 'some value'它的值有效并且标题打印在控制台上但api_key会发生变化,这就是我使用的原因,$http_api_key以便api_key自定义标题中的任何内容在从其余客户端发送时被接收。我已经尝试了几个解决方案,proxy_set_header api_key $upstream_http_api_key;但没有帮助。我想接收从 nodejs 中的休息客户端发送的任何自定义标头。
reverse-proxy nginx http-headers node.js nginx-reverse-proxy
希望有人能指出我正确的方向。我一直试图让它工作好几个小时:(
场景 - 我有一个 DMZ,我在其中设置了 Apache 服务器。我需要安全地与内部服务器通信,在那里我设置了另一个 Apache 服务器,该服务器再次反向代理到服务器内的本地主机应用程序..所以,基本上..
外部世界 > 互联网 ( https://app1.com ) > dmz (apache 反向代理) > 内部服务器 (apache 反向代理 - https://app1prod.com ) > (http) > localhost:8080
现在,在 dmz 中,我可以毫无问题地直接访问https://app1prod.com。但是,我终生无法从 dmz获取https://app1.com工作。我收到一条“503 服务不可用”消息:( 这是我在 dmz 中的 apache 配置..
<VirtualHost *:443>
ServerName app1.com
ProxyRequests off
SSLProxyCheckPeerName off
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerExpire off
LogLevel debug
SSLEngine on
SSLProxyEngine on
SSLCertificateFile "xxx/cert.crt"
SSLCertificateKeyFile "xxx/key.key"
SSLCertificateChainFile "xxx/certchain.crt"
ProxyPass / https://app1prod.com/
ProxyPassReverse / https://app1prod.com/
<Proxy *>
order deny,allow …Run Code Online (Sandbox Code Playgroud) 我创建了一个小的 hello world 节点应用程序,然后我将该应用程序托管在数字海洋液滴上,之后我可以在http://my_public_ip:3000上访问我的应用程序
感到快乐
然后我从 freenom.com购买了一个名为helloworld.tk免费域的域名之后,我在我的 Droplet 中安装了 nginx 作为网络服务器,然后我在 /etc/nginx/sites-enable/default 中添加了一个反向代理代码
我的代码看起来像:
server {
listen 80;
server_name helloworld.tk
location / {
proxy_pass http://localhost:3000;
}
}
Run Code Online (Sandbox Code Playgroud)
之后,我转到我的 freenom.com 中的域管理面板并将 url 转发设置为http://my_public_ip
因此,如果我在浏览器中输入我的域名helloworld.tk,我的节点应用程序成功运行,但等待我的 ip 地址显示在 chrome 左下角的左侧,如果我多次刷新页面,我会得到
402 Too many request error page on nginx
Run Code Online (Sandbox Code Playgroud)
所以我删除了我的 url 转发,在我的域管理面板而不是 url 转发中,我将我的名称服务器设置为 ns1.digitalocean.com bla.bla.bla ...
然后我在我的数字海洋面板中添加了我的域。现在是的,一切正常。
如果我点击我的 url 没有显示 ip 地址,也没有太多的请求错误
我的节点应用程序成功执行!
等等,我是托管节点应用程序的初学者,所以我需要帮助是否在生产中为节点应用程序正确设置?
url 转发和名称服务器有什么区别?我的nginx反向代理代码是否正确?我的反向代理工作正常吗?
注意:我使用 pm2 在后台运行节点应用程序。
我想弄清楚如何使用 Nginx 在 Heroku 应用程序上构建反向代理。问题是 Heroku 似乎每个应用程序只接受一个容器。但我的应用系统至少会使用三个容器:
那么可以用 Heroku 做到这一点吗?我的意思是,在同一域上以某种方式或另一种方式部署多容器应用程序?这将是非常棒的。如果有人有任何提示,那就太好了。谢谢。
我已成功将 Nginx 配置为我的 Web 应用程序的反向代理。它正确地将从我的 Angular SPA 发出的请求重定向到用 Asp Core 2.1 编写的 Web API。但是,在我的 Web API 中,我想使用ws://mydomain.com/ws用于建立连接的WebSockets
。
这就是我现在可用的网站的样子
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /etc/***/***.crt;
ssl_certificate_key /etc/***/***.key;
root /home/***/***/***/wwwroot;
# Add index.php to the list if you are using PHP
index index.html;
server_name my.domain.com;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:5000;
}
location /api/signalr {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $host; …Run Code Online (Sandbox Code Playgroud) 我正在尝试让 docker-compose 运行 NGINX 反向代理,但我遇到了一个问题。我知道我正在尝试的事情似乎是可能的,因为它概述如下:
https://dev.to/domysee/setting-up-a-reverse-proxy-with-nginx-and-docker-compose-29jg
和这里:
我的应用程序非常简单 - 它有一个前端和一个后端(nextjs 和 nodejs),我将它们与一个 nginx 实例一起放入 docker-compose 中。
这是 docker-compose 文件:
version: '3'
services:
nodejs:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
container_name: nodejs
restart: unless-stopped
nextjs:
build:
context: ../.
dockerfile: Dockerfile
ports:
- "3000:3000"
container_name: nextjs
restart: unless-stopped
webserver:
image: nginx:mainline-alpine
container_name: webserver
restart: unless-stopped
ports:
- "80:80"
volumes:
- web-root:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
depends_on:
- nodejs
- nextjs
networks:
- app-network
volumes:
certbot-etc:
certbot-var:
web-root:
driver: local
driver_opts: …Run Code Online (Sandbox Code Playgroud) 我想设置一个 nginx 实例,它将从 /api 开始的 HTTP 请求代理到 HTTPS 服务器,但应该省略 /api URL 段。例如,实例应该侦听 localhost:9817。如果它收到对http://localhost:9817/api/auth的请求,它应该将其代理为https://api.com:8443/auth。
这是我的 nginx 配置:
events {
worker_connections 1024;
}
http {
server {
listen 9817;
server_name localhost;
location /api {
rewrite ^/api(/.*) $1 break;
proxy_pass https://api.com:8443;
proxy_set_header Host $host;
proxy_http_version 1.1;
}
location / {
root "D:/Project/dist";
try_files $uri $uri/ /index.html;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我在 error.log 中收到以下错误:
2020/01/16 17:54:22 [error] 420512#426216: *31 peer closed connection in SSL handshake (10054: An existing connection was forcibly …Run Code Online (Sandbox Code Playgroud) 我计划设置 ALB (Amazon Load Balancer) 以进行身份验证。它会坐在我的客户端应用程序,并与和的access_token用户要求的智威汤逊页眉只转发认证请求前,x-amzn-oidc-accesstoken+x-amzn-oidc-data分别为[0]。
我的客户端应用程序需要捕获这些转发的标头并将它们存储在 localStorage 中,以便在以后的请求(例如 S3)中访问其他 AWS 资源。
如果我是接收 ALB 请求的客户端应用程序,我将如何拦截这些标头?他们是作为请求还是响应进来的?
[0] 参见图中的第 10 步:https : //www.exampleloadbalancer.com/auth_detail.html
reverse-proxy ×10
nginx ×6
apache ×2
docker ×2
http-headers ×2
https ×2
node.js ×2
ssl ×2
apache2 ×1
etherpad ×1
heroku ×1
http ×1
mod-proxy ×1
nameservers ×1
networking ×1
proxy ×1
security ×1
websocket ×1