2013-02-26 67 views
-1

我想重定向一个特定的URL到本地服务器运行在不同的端口上,不知道我需要添加到nginx.config。谢谢!ngnix配置URL特定的重定向

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/*; 
} 

回答

2

使用proxy pass

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