-1

特定の URL を別のポートで実行されているローカル サーバーにリダイレクトしたいのですが、nginx.config に何を追加する必要があるかわかりません。ありがとう!

e.g:  for url /v1/jobs
I want to direct it to a local server running on port 9090

以下は私の現在のnginx構成設定です:

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;    

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
4

1 に答える 1

2

プロキシパスを使用する

  location ^~ /v1/jobs {
    proxy_pass http://www.domain.com:9090
  }

URIはそのまま保持されます。必要に応じて、プロキシパスの前にリライトを使用してURIを変更できます。

nginxを再起動するには

  • どちらかnginx -s reload
  • またはHUPをプロセスに送信しますkillall -HUP nginx
  • またはサービスを再開しますservice nginx restart
  • また/etc/init.d/nginx restart
于 2013-02-26T09:50:09.210 に答える