使用以下代码段,每个人都可以访问 /foo 和 /bar
ProxyPass /foo http://example.com/foo
ProxyPassReverse /foo http://example.com/foo
ProxyPass /bar http://example.com/bar
ProxyPassReverse /bar http://example.com/bar
Run Code Online (Sandbox Code Playgroud)
但是,如果我希望每个人都可以访问 /foo,而 /bar 仅适用于来自特定 IP 的请求,这可能吗?
没有邪恶的计划,我试图在其他域下镜像站点,同时动态更改一些字符串。
我在新主机上设置了 nginx 作为主站点的 RP。这允许设置一个替换规则:
sub_filter Originalstring 'new string';
sub_filter_once off;
Run Code Online (Sandbox Code Playgroud)
但是,我想运行多个规则,其中sub_filter 每个位置只允许一个。
如果有的话,这里有什么解决方案?
有人可以启发我将 NginX 作为 Apache 的反向代理有什么好处。人们建议这样做,静态内容由 nginx 处理,动态内容(php 文件)交给 Apache。
直接让 php-fcgi/php-fpm 处理这些 PHP 文件不是比让 Apache 的 mod_php 处理更合理吗?
有什么优点(性能方面)
如果我选择反向代理,我是否需要进行 nginx 重写,或者来自 apache 的 .htaccess 是否可以正常工作?(因为它的反向代理,所以调用被定向到 apache 对吗?)
提前 TY
我正在尝试使用 ProxyPass 和 ProxyPassReverse 将请求通过 Apache 代理到另一个服务器实例,该实例在 Vhost 存在的不同 TCP 端口上绑定到本地主机(当目标绑定到:5000 时,VHost 绑定到:80)。
但是,我在访问位置时反复收到 HTTP 503。
根据ProxyPass 文档...
<VirtualHost *:80>
ServerName apacheserver.domain.local
DocumentRoot /var/www/redmine/public
ErrorLog logs/redmine_error
<Directory /var/www/redmine/public>
Allow from all
Options -MultiViews
Order allow,deny
AllowOverride all
</Directory>
</VirtualHost>
PassengerTempDir /tmp/passenger
<Location /rhodecode>
ProxyPass http://127.0.0.1:5000/rhodecode
ProxyPassReverse http://127.0.0.1:5000/rhodecode
SetEnvIf X-Url-Scheme https HTTPS=1
</Location>
Run Code Online (Sandbox Code Playgroud)
我已经测试了将备用服务器绑定到接口 IP 地址,并且出现了同样的问题。
服务器服务请求是 python paste:httpserver 的一个实例,它已被配置为使用 /rhodecode 后缀(正如我在其他关于 ProxyPass 的帖子中看到的那样)。项目本身的文档Rhodecode 报告使用了上述内容。
如果我的目标是在不同端口上提供服务的另一台服务器,则问题仍然存在。
ProxyPass 是否允许代理到不同的 TCP 端口?
[更新]
我不会删除它,以防有人遇到同样的问题。
我设置了一个 ErrorLog,在那个 ErrorLog …
有一种情况,首先所有当前请求都应该像它们当前针对某个域名一样工作。例如 www.hello.com
一动态DNS是要指向www.hello.com服务器相同的静态IP(somedomain.dnsdynamic.com ---> XXX.XXX.XXX.XXX)
所有请求,包括 GET、POST 等,都将被代理到主机名为 finalserver.example.com 的另一台服务器。(注意这个服务器没有静态ip,所以必须使用主机名)
代理应该只在 www.hello.com 服务器收到服务器名称为 somedomain.dnsdynamic.com 的请求时工作
已经尝试记住这个答案但失败了,要么得到 502 bad gateway 要么 404 page not found
我在单个 IP 地址上运行 Proxmox 服务器,它将根据请求的主机向容器发送 HTTP 请求。
我在 Proxmox 端使用 nginx 来监听 HTTP 请求,我proxy_pass在不同server块中使用指令根据server_name.
我的容器在 Ubuntu 上运行,同时也在运行一个 nginx 实例。
我在完全静态的特定网站上缓存时遇到问题:在文件更新后,nginx 继续为我提供陈旧的内容,直到我:
proxy_cache off为此服务器设置并重新加载配置这是我的配置的详细信息:
在服务器上(proxmox):
/etc/nginx/nginx.conf:
user www-data;
worker_processes 8;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
use epoll;
}
http {
##
# 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 64;
# server_name_in_redirect off; …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个反向代理,以只允许几个选定的 ip 范围代理到内部主机,而我希望不在 ip 范围内的任何其他人重定向到我们的内部命名主机。在此设置中,网络服务将正常工作,而没有通过 VPN 连接到我们网络的任何人都无法导航到内部资源。我一直试图让它在没有运气的情况下工作,我的部分配置目前如下:
ProxyRequests Off
<Proxy *>
Allow from all
</Proxy>
<Location />
Allow From xxx.xxx.xxx.xxx/24 1xxx.xxx.xxx.xxx/23
Deny From All
ProxyPass http://server.local.corp:8000/
ProxyPassReverse http://server.local.corp:8000/
</Location>
Run Code Online (Sandbox Code Playgroud)
此配置似乎可以很好地阻止其他 ip 范围进行代理,但是我不清楚如何为其他人添加重定向语句。
编辑 从第一个答案中获取建议我的代码现在看起来像:
<If "%{REMOTE_ADDR} -ipmatch 'xxx.xxx.xxx.xxx/24'">
ProxyPass / http://server.local.corp:8000/
ProxyPassReverse / http://server.local.corp:8000/
</If>
Run Code Online (Sandbox Code Playgroud)
并且 apache 在重启时抛出以下错误:
ProxyPass cannot occur within <If> section
Action 'configtest' failed.
The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud) 首先是一些背景:我们有一个嵌入式设备,可以将许多小事件上传到 Web 服务器。分块编码用于发布此信息。每个事件都作为一个单独的块发送,因此网络服务器 (node.js) 可以立即对事件做出反应。所有这一切都像一种魅力。
禁用服务器并在服务器上运行 netcat 显示设备发送的内容:
sudo nc -l 8080
POST /embedded_endpoint/ HTTP/1.1
Host: url.com
User-Agent: spot/33-dirty
Transfer-Encoding: chunked
Accept: text/x-events
Content-Type: text/x-events
Cache-Control: no-cache
120
{"some","json message"}
232
{"other","json event"}
232
{"and a lot more","up to 150 messages per second!"}
0
Run Code Online (Sandbox Code Playgroud)
现在我在我的网络服务器上安装了 nginx(版本 1.6.0)。最后我希望它处理 SSL 并且我想处理加速正常的网络流量。
如果我现在使用此服务器配置启用 nginx:
server {
listen 8080;
location / {
proxy_http_version 1.1;
expires off;
proxy_buffering off;
chunked_transfer_encoding on;
proxy_pass http://localhost:5000;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我收到这个:
sudo nc -l 8080
POST /embedded_endpoint/ HTTP/1.1
Host: localhost:5000 …Run Code Online (Sandbox Code Playgroud) 我们的组织正在改造它的网站。有人在新服务器上建立了新站点。将条目放入 /etc/hosts 后即可访问它。并且以这种方式访问时可以完美运行。
但是由于涉及的大多数人都不擅长计算机,因此我决定设置反向代理。
我无权访问该站点,也无权托管它的服务器。我在那里安装了 Wordpress 的编辑器帐户。
我在我的私人服务器的 /etc/hosts 中放置了一个条目并使用以下配置设置反向代理,我的服务器在 Debian stable 下运行 apache-2.2:
<VirtualHost *:80>
ServerName xxx.xxx.xxx.xxx
ProxyRequests off
ProxyPass /some/prefix/ http://site.example.com/
ProxyPassReverse /some/prefix/ http://site.example.com/
ProxyHTMLURLMap http://site.example.com/ http://xxx.xxx.xxx.xxx/some/prefix/
<Location /some/prefix/>
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLURLMap http://site.example.com/ /some/prefix/
</Location>
ProxyPassReverseCookieDomain site.example.com xxx.xxx.xxx.xxx
ProxyPassReverseCookiePath / /some/prefix/
ProxyHTMLExtended On
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
几乎一切正常。我无法发布新帖子(文本编辑器未正确加载)。Iceweasel 的 (Firefox) 开发者模式说:
(...)
[00:13:33.365] GET http://xxx.xxx.xxx.xxx/some/prefix/wp-includes/js/tinymce/langs/pl.js?wp-mce-4107-20141130 [HTTP/1.1 404 Not Found 399ms]
(...)
[00:13:33.648] Failed to load: http://xxx.xxx.xxx.xxx/some/prefix/wp-includes/js/tinymce/langs/pl.js
[00:13:46.733] POST http://xxx.xxx.xxx.xxx/wp-admin/admin-ajax.php [HTTP/1.1 404 Not Found 102ms]
Run Code Online (Sandbox Code Playgroud)
我省略了非错误。在我看来,Apache 并没有重写某些东西。有任何想法吗?
我正在尝试在 centos 7 虚拟机上使用 nginx 作为负载平衡器来替换老化的 Coyote Point 硬件设备。但是,在我们的一个 web 应用程序中,我们在日志中看到频繁且持续的上游超时错误,并且客户端在使用系统时报告会话问题。
这是我们 nginx.conf 中的相关部分
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
upstream farm {
ip_hash;
server www1.domain.com:8080;
server www2.domain.com:8080 down;
server www3.domain.com:8080;
server www4.domain.com:8080;
}
server {
listen 192.168.1.87:80;
server_name host.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 192.168.1.87:443 ssl;
server_name host.domain.com;
## Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 4;
gzip_http_version 1.0;
gzip_min_length 1280;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript …Run Code Online (Sandbox Code Playgroud) reverse-proxy ×10
nginx ×6
apache-2.2 ×3
apache-2.4 ×1
cache ×1
chunked ×1
http ×1
httpd ×1
proxy ×1
proxypass ×1
request ×1
rewrite ×1
selinux ×1
wordpress ×1