我正在寻找的是用nginx设置一个反向代理,并将它们转发到另一个nginx服务器。反向代理应将所有到all服务器的通信量转发到相关端口。
Nginx反向配置:
server {
listen 80;
root /var/www/;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.10:1478;
}
location ~ /\.ht {
deny all;
}
}在这种情况下,反向应将所有流量重定向到the服务器192.168.0.10:1478
Nginx Webserver配置:
server {
listen 1478;
root /var/www/public_html;
index index.html index.htm index.php;
server_name IP-Reverse;
}这不管用..。是否存在配置错误?
在这种情况下,我使用两个服务器,一个one服务器nginx和一个反向nginx。应该禁止从反向代理到特定端口上的All服务器的所有流量。从反向代理到the服务器的所有请求应该只允许来自反向ip
发布于 2015-08-22 15:24:48
错误代码:错误请求(400),问题是我的日志文件中没有任何内容。
这是我的This服务器vhost配置:
server {
listen 7894 ;
server__name srv1.domain.com;
root /var/www/public_html;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}这是我的反向配置:
server {
listen 80;
listen 443 ssl;
server_name domain.com;
root /var/www/public_html;
index index.html index.htm index.php;
error_log /var/log/nginx/error.log;
charset utf-8;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://webserveripaddress:7894;
}
location ~ /\.ht {
deny all;
}
####SSL####
ssl_certificate /etc/ssl/domain.crt;
ssl_certificate_key /etc/ssl/domain.key;
}希望这能有所帮助。非常感谢!
https://stackoverflow.com/questions/32151097
复制相似问题