centos7 seafile 6.2.3 nginx 1.10.2 反向代理设置问题


#1

如题:centos7 seafile 6.2.3 nginx 1.10.2 反向代理设置问题 。seafile已经搭建成功,局域网用可以通过192.168.1.105:8000,访问。
目的:想让局域网用户通过192.168.1.105 直接访问seafile。怎么设置nginx的.conf文件。
已经在网上设置太多,都实现不了。
/etc/nginx/conf/nginx.conf配置如下。


#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {

#    listen       80;
 #   server_name  192.168.1.105;
  #  rewrite ^ https://$http_host$request_uri? permanent;
   # }
 server {
  listen 80;
# ssl on;
# ssl_certificate /etc/ssl/cacert.pem;   #cacert.pem 
 # ssl_certificate_key /etc/ssl/privkey.pem;     #privkey,pem  wen jian   lu  jing
 server_name 192.168.1.105;    #my  yu ming
 proxy_set_header X-Forwarded-For $remote_addr;
 location / {
 proxy_pass http://127.0.0.1:8000;
 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-Host $server_name;
 proxy_read_timeout 1200s;
 client_max_body_size 0;
 access_log /var/log/nginx/seahub.access.log;
  error_log /var/log/nginx/seahub.error.log;
}
   #fastcgi_pass http://192.168.1.105:8000;  #duan kou  hao
 #fastcgi_param     SCRIPT_FILENAME $document_root$fastcgi_script_name;
 #fastcgi_param  PATH_INFO     $fastcgi_script_name;

 #fastcgi_param  SERVER_PROTOCOL  $server_protocol;
# fastcgi_param  QUERY_STRING     $query_string;
# fastcgi_param  REQUEST_METHOD    $request_method;
# fastcgi_param  CONTENT_TYPE      $content_type;
# fastcgi_param  CONTENT_LENGTH    $content_length;
# fastcgi_param  SERVER_ADDR       $server_addr;
# fastcgi_param  SERVRR_PORT       $server_port;
# fastcgi_param  SERVER_NAME       $server_name;
# fastcgi_param  HTTPS                 on;
# fastcgi_param  HTTP_SCHEME       https;
# access_log    /var/log/nginx/seahub.access.log;
# error_log         /var/log/nginx/seahub.error.log;
     
 
    #charset koi8-r;

    #access_log  logs/host.access.log  main;
location / {
 rewrite ^/seafhttp(.*)$ $1 break;
 proxy_pass http://127.0.0.1:8082;
 client_max_body_size 0;
 proxy_connect_timeout 36000s;
 proxy_read_timeout  36000s;
    }
location /media {
    root /seafile/seafile-server-latest/seahub;    #seahub lu  jing
}

    location / {
        root   html;
        index  index.html index.htm;
    }

    #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   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;
    #}



# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}


#2

nginx的虚拟主机,直接添加
upstream test{
server 192.168.1.105:8000;
}
server {
listen 80;
server_name 192.168.1.105; #域名

    location / {
         proxy_set_header HOST $HOST;
         proxy_pass http://test;
    }

}