haproxy nginx tomcat
マシンにhaproxy nginx tomcatを搭載したアーキテクチャモデル
haproxyがない場合nginxリスニング80ポートはダイナミックリクエストをバックエンドの8080に転送する
haproxyがある後haproxyリスニング80はnginxの8001 nginxに転送して動的な要求を話してtomcatの8080に転送します
しかし、要求されたurlの後ろに8001ポートが含まれているという問題があります.
最後に解決策を見つけた
nginxでconf
これで8001はありません
haproxy.conf
その後8001がまた現れました
一つ配られたので
rewrite/mmm /fff permanent;
これで転送後にまた8001が現れた
解決策
rewrite/mmm http://beta.google.cn/fff permanent;
現象を見るとnginx内部転送すると、あなたが何のポートから来たのか、何のポート8001に転送されたのか、自然に8001に転送されます.
でも外から来たら80来ます
ネット上で関連資料を探します
haproxyがない場合nginxリスニング80ポートはダイナミックリクエストをバックエンドの8080に転送する
haproxyがある後haproxyリスニング80はnginxの8001 nginxに転送して動的な要求を話してtomcatの8080に転送します
しかし、要求されたurlの後ろに8001ポートが含まれているという問題があります.
最後に解決策を見つけた
nginxでconf
server {
listen 8001;
server_name beta.google.com;
location / {
proxy_pass http://tomcat;
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;
これで8001はありません
haproxy.conf
listen lbserver *:80
cookie JSESSIONID prefix
# - equal weights on all servers
# - maxconn will queue requests at HAProxy if limit is reached
# - minconn dynamically scales the connection concurrency (bound my maxconn) depending on size of HAProxy queue
# - check health every 20000 microseconds
option httpchk GET /index
server nginx1 127.0.0.1:8001 weight 1 minconn 3 maxconn 6 check inter 20000
server tomcat2 127.0.0.1:8082 weight 1 minconn 3 maxconn 6 check inter 20000
その後8001がまた現れました
一つ配られたので
rewrite/mmm /fff permanent;
これで転送後にまた8001が現れた
解決策
rewrite/mmm http://beta.google.cn/fff permanent;
現象を見るとnginx内部転送すると、あなたが何のポートから来たのか、何のポート8001に転送されたのか、自然に8001に転送されます.
でも外から来たら80来ます
ネット上で関連資料を探します
Hi, everyone.
I have a server running a php web forum. User logging into my site
using 'logging.php'.
I had set up a https server using nginx, but consdering server load, I
just want my user using https in only logging.php.
I want to settle this by using url rewrite. When my users click
http://mysite.com/logging.php,
nginx will automatic change the url to
https://mysite.com/logging.php
. And when my user click any other links
in my site, for example, https://mysite.com/index.php,
nginx will
change https to http.
Can rewrite work like this?
Thank you!
BTW,changing my forum codes may work, but I didn't know much about php
coding...so, I want to settle this in nginx rewrite...
In your plain http server block:
if ($uri ~* "/logging.php$") {
rewrite ^/(.*)$ https://$host/$1
redirect;
}
In your https server block
if ($uri !~* "/logging.php$") {
rewrite ^/(.*)$ http://$host/$1
redirect;
}
This is when you are using standard ports (80 for HTTP and 443 for
HTTPS). If you are using non-standard ports (say 8080 for http, and 8443
for https, then in this case, you should have in your http block)
if ($uri ~* "/logging.php$") {
rewrite ^/(.*)$ https://$host:8443/$1
redirect;
}
and correspondingly, in your https block, you should have:
if ($uri !~* "/logging.php$") {
rewrite ^/(.*)$ http://$host:8080/$1
redirect;
}
The $host variable is the host portion of the URL that was used to reach
your server
See http://wiki.codemongers.com/NginxHttpCoreModule
for the list of
variables