2017-11-02 9 views
1

あなたは私がhttp://bla.domain.comは、下のリンクを指すようにしたい、次のnginxの仮想のconf + qwebirc + proxy_pass + index.htmlを

を達成するために私を助けてもらえます。私は、元のnginxのもの続いている

http://bla.example.com:4321/?nick=Nick.....&amp&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1 

- 現時点では>https://www.nginx.com/resources/wiki/start/topics/recipes/qwebirc/

を私はそれ

たいとのindex.htmlが提示されなかったとき、誰かオープンだから、別の、より良い解決策は次のようになりますbla.example.comを開いて穴のリンク(http://bla.example.com:4321/?nick=Nick.....&amp&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1)を開きますが、覚えにくいので、穴のリンクを表示したくありません。

私は今までに行った設定を以下で確認できます。

server { server_name bla.example.com; 

    location/{ 
      autoindex on; 
      autoindex_exact_size off; 
      root /home/user/qwebirc/; 
      index index.html; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header Host $host; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_buffering off; 
      proxy_pass http://127.0.0.1:4321; 
    } 

    #location/{ 
    #  autoindex on; 
    #  autoindex_exact_size off; 
    #  root /home/user/qwebirc/; 
    #  index index.html; 
    #  try_files $uri $uri/ @proxy; 
    #} 

    #location @proxy { 
    #  proxy_set_header X-Real-IP $remote_addr; 
    #  proxy_set_header Host $host; 
    #  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    #  proxy_buffering off; 
    #  proxy_pass http://127.0.0.1:4321; 
    #} 

    location ~* \.php$ { 
     #include fastcgi.conf # I include this in http context, it's just here to show it's required for fastcgi! 
     try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0 in php.ini (you should!) 
     fastcgi_pass 127.0.0.1:9000; 
    } 

    ### Logs ### 
    access_log /var/log/nginx/example.com.access.log; 
    error_log /var/log/nginx/example.com.error.log; 

} 

私は今の代わりに作業のコメントのものでそれを実行しようとしていることを心に留めておいてください。

また、ここでは、以下のホーム/ユーザー/ qwebirc /にあるindex.htmlには/

<html lang="en" class="no-js"> 
    <head> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="width=device-width,initial-scale=1.0"> 
     <style> 
     html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
     <script> 
     var calcHeight = function() { 
      $('#preview-frame').height($(window).height()); 
     } 

     $(document).ready(function() { 
      calcHeight(); 
     }); 

     $(window).resize(function() { 
      calcHeight(); 
     }).load(function() { 
      calcHeight(); 
     }); 
     </script> 
    </head> 
    <body> 
     <iframe id="preview-frame" src="http://bla.example.com/?nick=Nick.....&amp&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&amp;prompt=1" name="preview-frame" frameborder="0" noresize="noresize"> 
     </iframe> 
    </body> 
</html> 

答えて

0

あなたがルートURIにクエリ文字列を追加し、プロキシにそれを通過しています。プロキシを2つのlocation blocksに分割するのが最も簡単です.1つはルートURI用で、もう1つは他のすべてのURI用です。一般的なproxyステートメントは、外側ブロックに移動して両方で継承できます。

server { 
    server_name bla.example.com; 

    root /home/kiril/qwebirc; 
    index index.html; 

    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header Host $host; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_buffering off; 

    location =/{ 
     proxy_pass "http://127.0.0.1:4321/?nick=Nick.....&amp&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&amp;prompt=1"; 
    } 
    location/{ 
     proxy_pass http://127.0.0.1:4321; 
    } 

    location ~* \.php$ { 
     try_files $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
    } 

    access_log /var/log/nginx/bla.example.com.access.log; 
    error_log /var/log/nginx/bla.example.com.error.log; 
} 

それが埋め込ま;が含まれてproxy_pass値は引用符で囲まれています。

+0

私は上記のシナリオでそれをテストしますが、構文は大丈夫ですが目標は達成されません。だからlocation = /はうまくいかないようです。基本的には以前と同じです。 – user3599612

0

現在の設定はこのように見え、動作していません。私はnginxを開始することはできません。

server { server_name bla.example.com; 

    location/{ 
      autoindex on; 
      autoindex_exact_size off; 
      root /home/kiril/qwebirc/; 
      index index.html; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header Host $host; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_buffering off; 
      #proxy_pass http://127.0.0.1:4321; 
    } 

    location =/{ 
     proxy_pass "http://127.0.0.1:4321/?nick=Nick.....&amp&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&amp;prompt=1"; 
    } 

    location/{ 
     proxy_pass http://127.0.0.1:4321; 
    } 

    location ~* \.php$ { 
     #include fastcgi.conf # I include this in http context, it's just here to show it's required for fastcgi! 
     try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0 in php.ini (you should!) 
     fastcgi_pass 127.0.0.1:9000; 
    } 

    ### Logs ### 
    access_log /var/log/nginx/bla.example.com.access.log; 
    error_log /var/log/nginx/bla.example.com.error.log; 

} 
上記の場所にコメントを解除 proxy_pass http://127.0.0.1:4321;

/及びその下にそれを削除するには、働いているが、それは同じです。まだ必要なものを達成することはできません。

+0

2つの 'location /'ブロックがあるので、設定はロードされません。これはエラーです。エラーログを参照するか、 'nginx -t'で設定をテストしてください。私は外側のブロックのコンテキストを表示するために私の答えを更新しました。 –

関連する問題