- 论坛徽章:
- 0
|
谁能解释一下?
default.conf中上面的80端口的http前端转发时昨天测好的,没问题;今天这个https转发是刚刚测好的,也没问题,
但是2者的区别,location在http转发时必须带/,而http啥的必须不带/,否则地址不对报错。
location /site1/ {
proxy_pass http://192.168.137.12;
}
location /site2/ {
proxy_pass http://192.168.137.13;
}
以下是https带着/和不带/的错误和正确的日志。
192.168.137.11 - - [04/May/2013:16:40:01 +0800] "GET /page1.html HTTP/1.0" 404 168 "-" "Opera/9.80 (Windows NT 6.1; Edition Next) Presto/2.12.388 Version/12.12"
192.168.137.11 - - [04/May/2013:16:40:43 +0800] "GET /site2/page1.html HTTP/1.0" 200 30 "-" "Opera/9.80 (Windows NT 6.1; Edition Next) Presto/2.12.388 Version/12.12"
default.conf的配置文件如下
[root@nginx1 conf.d]# more default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
#root /usr/share/nginx/html;
root /home/root/web;
index index.html index.htm;
location /site1/ {
proxy_pass http://192.168.137.12/site1/;
}
location /site2/ {
proxy_pass http://192.168.137.13/site2/;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
### server port and name ###
listen 443 ssl;
server_name main443;
ssl on;
### SSL log files ###
access_log /var/log/nginx/ssl-access.log;
error_log /var/log/nginx/ssl-error.log;
### SSL cert files ###
ssl_certificate ssl/main.crt;
ssl_certificate_key ssl/main.key;
### Add SSL specific settings here ###
keepalive_timeout 60;
### Limiting Ciphers ########################
# Uncomment as per your setup
#ssl_ciphers HIGH:!ADH;
#ssl_perfer_server_ciphers on;
#ssl_protocols SSLv3;
##############################################
### We want full access to SSL via backend ###
location / {
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
### Set headers ####
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
proxy_set_header X-Forwarded-Proto http;
### By default we don't want to redirect it ####
#proxy_redirect off;
location /site1/ {
proxy_pass http://192.168.137.12;
}
location /site2/ {
proxy_pass http://192.168.137.13;
}
}
}
[root@nginx1 conf.d]# |
|