我正在为我的应用程序设置一个代理服务器。用例是我想要一个特定的请求redirect到说abc.com和其余的请求被redirect到xyz.com 。 例如:如果用户请求www.nginx.com ,它应该去nginx.com:8000,其余的请求应该去sites.nginx.com
server { # Listen on port 80 for all IPs associated with your machine listen 80; # Catch only requests for www.nginx.com server_name www.nginx.com; location / { # Pass the request to your Apache server running on IP xxxx and port 8000 proxy_pass http://www.nginx.com:8000; } } # Server for S3 server { # Listen on port 80 for all IPs associated with your machine listen 80; # Catch all other server names server_name _; # This code gets the host without www. in front and places it inside # the $host_without_www variable set $host_without_www $host; if ($host ~* www\.(.*)) { set $host_without_www $1; } location / { # This code rewrites the original request, and adds the host without www in front # Eg if someone requests # /directory/file.ext?param=value # from the coolsite.com site the request is rewritten to # /coolsite.com/directory/file.ext?param=value rewrite ^(.*)$ /$host_without_www$1 break; # The rewritten request is passed to S3 proxy_pass http://sites.nginx.com; } }
但是目前我相信第二块有一些问题。我已经在S3上configuration了一个代理到静态网站的域(规则是相应地写的)。 但不是在桶内取文件夹名称,而是用文件夹名称search桶并返回以下错误。
404 Not Found Code: NoSuchBucket Message: The specified bucket does not exist BucketName: www.gobiggi.co.in RequestId: 62258F8B3F01AB4C HostId: f0hxEF/kGTwfwu4uoZ3JxXpdak+vNtLQU9+mfcyg3m8ybIsty9GzbSLnU01jdvVX
例如:我有一个存储桶sites.nginx.com(bucket name)/www.abc.com(folder name) 。现在我希望它与文件夹名称相匹配,但它会查找名为www.abc.com的存储桶
如果我把它传递给任何其他域名www.xyz.com而不是桶,它的工作原理。
我需要帮助以正确的方式进行configuration。 感谢您的时间。