Php 用于重写规则的NGINX配置文件中的Concat值

Php 用于重写规则的NGINX配置文件中的Concat值,php,amazon-web-services,nginx,amazon-s3,Php,Amazon Web Services,Nginx,Amazon S3,我正在配置我的nginx配置文件defualt.conf以获得重写规则,以接受请求并将它们路由到S3存储桶。 现在,我正在为URL的后半部分获取正确的内容,但我无法解析或预编S3 bucket的URL 这是我的代码: location / { # This code rewrites the original request, and adds the host without www in front # E.g. if someone requests


我正在配置我的nginx配置文件
defualt.conf
以获得重写规则,以接受请求并将它们路由到S3存储桶。
现在,我正在为URL的后半部分获取正确的内容,但我无法解析或预编S3 bucket的URL

这是我的代码:

  location / {
        # This code rewrites the original request, and adds the host without www in front
        # E.g. 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;
    } 
在上面的重写中,我想预先添加
site.nginx.com
,这是我在
/$host\u而不使用www
之前的bucket名,我尝试使用
(dot)和unix样式
{$variable\u to\u concat}
,但没有成功。
有人能给我建议正确的方法吗。

感谢您的关注

由于您的重写url与孔请求匹配,您可以使用以下简单配置:

location / {
    proxy_pass http://sites.nginx.com/coolsite.com/;
}

以下是

由于您的重写url与孔请求匹配,您可以使用以下简单配置:

location / {
    proxy_pass http://sites.nginx.com/coolsite.com/;
}

以下是

此站点的服务器名称是什么?当请求
/directory/file.ext?param=value
时,是否要获取内容
site.nginx.com/coolsite.com/directory/file.ext?param=value
这是存储在s3
sites.nginx.com(bucket name)/coolsite.com(folder name)/index.html(files)
中的静态站点结构。实际上,我试图解析的url有语法错误。我必须为日志启用调试模式,然后检查值。这解决了问题!谢谢我发布了另一个简单的配置,你可以试试。这个网站的服务器名是什么?当请求
/directory/file.ext?param=value
时,是否要获取内容
site.nginx.com/coolsite.com/directory/file.ext?param=value
这是存储在s3
sites.nginx.com(bucket name)/coolsite.com(folder name)/index.html(files)
中的静态站点结构。实际上,我试图解析的url有语法错误。我必须为日志启用调试模式,然后检查值。这解决了问题!谢谢我发布了另一个简单的配置,你可以试一试。是的,但是你如何定义变量?@Matt你所说的
concat
是什么意思?是的,但是你如何定义变量?@Matt你所说的
concat
是什么意思?