2017-03-06 4 views
0

NGINXからドメイン名http://home.comへのリクエストをproxy_pass http://localhost:8866;に転送します。私はルートroot /home/owncloud;をNGINX設定ファイルに設定しています。ここでownCloudのドキュメントルートがあります。これはhttp://home.com/owncloudを指すはずですhttp://localhost:8866の下に私はWordpressをホストしているDockerコンテナを持っています。私はすでに文書の多くを通じて閲覧が、現在私は - 私はhttp://home.comNginxデフォルト:ロケーションが/なぜリバースプロキシに転送されないのですか?

は、この上のご入力いただき、ありがとうございアクセスしようとするとしかし、nginxのは、常にサーバー(root /home/owncloud)の実際のドキュメントルートにリバースプロキシを指します自分で解決策を見つけることができません。ありがとう!あなたはすべての要求をあなたのローカルホストで別のポートを転送する必要がある場合は、単にこの必要

upstream php-handler { 
    server unix:/var/run/php5-fpm.sock; 
    } 

server { 
    listen 80; 
    server_name home.com; 
    index index.html index.htm index.php; 
    # enforce https 
    return 301 https://$server_name$request_uri; 
    } 


server { 
     ssl on; 
     listen 443 ssl; 
     server_name home.com; 
     server_name 123.456.789.10 ssl; 
     ssl_certificate /home/ssl/certificate.pem; 
     ssl_certificate_key /home/ssl/owncloud.key; 
     index index.html index.htm index.php; 

     root /space/owncloud; 
     try_files $uri $uri/ /index.php?q=$request_uri; 
     # Add headers to serve security related headers 
       add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; 
       add_header X-Content-Type-Options nosniff; 
       add_header X-Frame-Options "SAMEORIGIN"; 
       add_header X-XSS-Protection "1; mode=block"; 
       add_header X-Robots-Tag none; 

     # set max upload size 
     client_header_buffer_size 64k; 
     large_client_header_buffers 4 64k; 

     # Disable gzip to avoid the removal of the ETag header 
     gzip off; 

     rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; 
     rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; 
     rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; 

     index index.php index.html index.htm; 
     error_page 403 /core/templates/403.php; 
     error_page 404 /core/templates/404.php; 

    location =/{ 
       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 $scheme; 
       proxy_pass   http://localhost:8866; 
       proxy_read_timeout 90; 
     } 

    location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){ 
    deny all; 
    } 

    location = /favicon.ico { log_not_found off; access_log off; } 
    location = /robots.txt { log_not_found off; access_log off; allow all; } 
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { 
     expires max; 
     log_not_found off; 
     } 

     location ~ \.php$ { 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_index index.php; 
      include fastcgi_params; 
      proxy_pass_header Authorization; 
      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_http_version 1.1; 
      proxy_set_header Connection ""; 
      proxy_buffering off; 
    }  


      location /owncloud { 
      index index.html index.htm index.php; 

      rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; 
      rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; 
      rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; 

      error_page 403 /core/templates/403.php; 
      error_page 404 /core/templates/404.php; 

      location ~ \.php(?:$|/) { 
       fastcgi_split_path_info ^(.+\.php)(/.+)$; 
       include fastcgi_params 
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       fastcgi_param PATH_INFO $fastcgi_path_info; 
       fastcgi_param HTTPS on; 
       fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice 
       fastcgi_pass php-handler; 
       fastcgi_intercept_errors on; 
       fastcgi_buffer_size 128k; 
       fastcgi_buffers 4 256k; 
       fastcgi_busy_buffers_size 256k; 
       # attachments can be huge 
       client_max_body_size 513M; 
       client_body_in_file_only clean; 
       # this is where requests body are saved 
       client_body_temp_path /opt/nginx/bugzilla/data/request_body 1 2; 
     } 
    } 

      # deny access to .htaccess files, if Apache's document root 
      # concurs with nginx's one 
      # 
      location ~ /\.ht { 
        deny all; 
      } 
} 

答えて

0

これは私のnginxの設定ファイルである

location/{ 
    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 $scheme; 
    proxy_pass    http://localhost:8866$request_uri; 
    proxy_read_timeout 90; 
} 

注意を、ない「は=ありませんスラッシュの前に等号を付けてください。/location/{}は「/の完全一致」を意味します。 あなたのコードでは、実際にはすべてのリクエストをlocalhostに転送することはありません。インデックスページへのリクエスト(ドキュメントルート、つまり「/」)のみが転送されます。

あなたがローカルホストの処理にすべての要求を渡した場合:8866を使用すると、必ずあなたのproxy_pass作品を作ると、あなたがそれらを削除しても良いので、他のlocationセクションのいずれであっても、テストされません。

関連する問題