这比this article,
领先一步以下是当前的流程和配置,它正在运行。我可以从/ 16机器访问UI。这是由其他人完成的。我想按照上面的文章。
Client------------------nginx----------------------nginx
192.168.13.90/16 eth0 - 192.168.13.2/16 eth0 - 192.168.13.9/16
eth0.1 - 182.28.129.202/24
|
|
uWSGI
我是nginx和python的初学者。我想在以下场景中将{nginx配置为eth0.1
接口上的反向代理,
Client------------------nginx---------------------nginx
182.28.129.201/24 eth0 - 192.168.13.9/16 eth0 - 192.168.13.2/16
eth0.1 - 182.28.129.202/24
|
|
uWSGI
以下是我当前试用版的当前nginx配置文件。错误评论,
Edit2 - 从上游nginx反向代理服务器注释掉特殊login.html
页面的位置块
# /etc/nginx/nginx.conf
# 192.168.13.2/16 - this upstream server
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
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;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log /var/log/access.log;
error_log /var/log/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
以下是上面nginx.conf中包含的ui.conf文件, #etet/nginx/sites-enabled/ui.conf
# 192.168.13.2/16 - this upstream server
server {
listen 192.168.13.2:80;
server_name 192.168.13.2:80;
access_log /var/log/access.log;
error_log /var/log/error.log;
# No physical login.html,
# it is passing it to root which is login screen
#location = /login.html { <--------- Edit2
# return 301 /;
#}
location / {
include uwsgi_params;
uwsgi_pass unix:/var/run/ui.sock;
}
}
以下是不同子网上eth0.1
上的nginx.conf,
Edit1 - 我遇到此配置的问题是请求被代理到上游nginx服务器,但响应是gzip和chunked。我没有看到客户端上的页面加载。
Edit2 - 我为特殊页面login.html
添加了位置块,它加载了页面,但它停留在重定向页面上。请参阅下面的wireshark流,
# /etc/nginx/nginx.conf
# eth0 - 192.168.13.9/16
# eth0.1 - 182.28.129.202/24 - Reverse proxy
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 0; #Disable
gzip on;
gzip_disable "msie6"; # <----------- Edit2
server {
listen 182.28.129.202:8080;
server_name 182.28.129.202:8080;
#rewrite ^(.*) $scheme://$server_name$1 permanent;
location = /login.html { # <---------- Edit2
proxy_pass http://192.168.13.2:80/;
}
location / {
proxy_pass http://192.168.13.2:80;
# trial and error
#proxy_http_version 1.1;
#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 X-Forwarded-Proto http;
#proxy_bind 192.168.13.9;
#proxy_buffering off;
}
}
}
Edit2 - Wireshark流,停留在重定向页面,/ home
POST /login.html HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://182.28.129.202:8080/login.html
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: 182.28.129.202:8080
Content-Length: 33
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
password=xxxxxxxxxx&login-submit=Server: nginx/1.6.2
Date: Thu, 07 Dec 2017 20:10:50 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 239
Connection: close
Location: http://192.168.13.2/home
Set-Cookie: remember_token=admin|c8aa43aab8b27724a207eb28ac7d1034d1e274fc4f528002a2d6106bb7c36a41756f6951d518f632d426a7d8c8257ad00dbab78e3daf7a5bbbc723ba33107e5e; Expires=Fri, 07-Dec-2018 20:10:50 GMT; Path=/
Set-Cookie: session=.eJw1zksKwzAMRdG9eNyBLUeSnc0E2ZJoBgkln1Hp3msonT4uvPMOix92PsN8Hbc9wrJqmAMgdgOPWhJx06jSM-lEuUKN5CzelFJJJY-pRs5QDLkgRWsdPZZkTZETkRikws1gUufeRL0a9zhlHAlXFEDPYlLHW1RI3sAYwoC87Nhkt_360-7Tjh9PdFv38PkC4lY3Tg.DQsxyg.lZrpSNvXnwE-JHT5t6qlYLAQP4Y; Expires=Sun, 07-Jan-2018 20:10:50 GMT; HttpOnly; Path=/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/home">/home</a>. If not click the link.
首先,我尝试通过HTTP访问UI,然后使用HTTPS。由于我对这方面的了解,我无法继续前进,因此非常感谢任何指导。
谢谢,
答案 0 :(得分:0)
我做了很多试验和错误,那就是在哪里观察到奇怪的错误。以下是适用于我的配置文件。希望它能帮助一个人。
# 192.168.13.2/16 - this upstream server
server {
listen 192.168.13.2:80;
server_name 192.168.13.2:80;
access_log /var/log/access.log;
error_log /var/log/error.log;
# No physical login.html,
# it is passing it to root which is login screen
location = /login.html {
rewrite ^ http://192.168.13.2/ last;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/var/run/ui.sock;
}
}
# /etc/nginx/nginx.conf
# eth0 - 192.168.13.9/16
# eth0.1 - 182.28.129.202/24 - Reverse proxy
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 0; #Disable
gzip on;
gzip_disable "msie6";
server {
listen 182.28.129.202:8080;
server_name 182.28.129.202:8080;
location / {
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_pass http://192.168.13.2:80;
}
}
}