我无法将一些.htaccess规则转换为nginx服务器。 RewriteRule ^$ index.php [L] RewriteRule ^([A-Za-z0-9-]+)?$ index.php?section=$1 [L] RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?section=$1&go=$2 [L] RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?section=$1&go=$2&action=$3 [L] 有人能够帮助转换和解释这些正则expression式将如何转换为nginx? 我不确定的语法,根据nginx文档我已经尝试了以下内容: server { rewrite ^([A-Za-z0-9-]+)?$ index.php?section=$1&go=$2; } 我也尝试了一个根位置块,如下所示。 我不知道try_files如何影响这个。 location / { rewrite ^$ /index.php break; rewrite ^([A-Za-z0-9-]+)?$ /index.php?section=$1 break; rewrite ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?section=$1&go=$2 break; rewrite ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?section=$1&go=$2&action=$3 break; rewrite ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?section=$1&go=$2&action=$3&id=$4 break; try_files $uri $uri/ /index.php?$args; } […]
我试图通过https://www.obeythetestinggoat.com/book/chapter_manual_deployment.html来逐步了解当我从运行在我的VPS上的django网站请求一个页面时发生的情况。 如果我正确理解,当我浏览到“mysite.com”DNS查询发生redirect我的请求到Alogging这是我的Ubuntu服务器vps服务器运行nginx的IP地址。 我的nginxconfiguration文件看起来像这样: server { listen 80; server_name mysite.com; location / { proxy_pass http://localhost:8000; } } 我猜测,在这一点上,nginx(侦听端口80)能够查看请求和相关的http头,并将请求匹配到适当的nginx站点启用的configuration文件。 这个简单的心理模型是否正确? 我缺less什么重点?
我有一套专门的重写规则来适应多站点的cms设置。 我试图让nginx强制请求URL上的斜线。 我希望它redirect请求 domain.com/some-random-article to domain.com/some-random-article/ 我知道有这个语义上的考虑,但我想做SEO的目的。 这是我目前的服务器configuration。 server { listen 80; server_name domain.com mirror.domain.com; root /rails_apps/master/public; passenger_enabled on; # Redirect from www to non-www if ($host = 'domain.com' ) { rewrite ^/(.*)$ http://www.domain.com/$1 permanent; } location /assets/ { expires 1y; rewrite ^/assets/(.*)$ /assets/$http_host/$1 break; } # / -> index.html if (-f $document_root/cache/$host$uri/index.html) { rewrite […]
有什么办法来模拟这些错误? 我为它创build了一些自定义文件,但我想确保显示正确。 我为每个虚拟主机发出不同的信息。 先谢谢你。
是否有任何免费的,轻量级的单进程(例如multithreading, asynchronous )HTTP转发代理软件? Tinyproxy效果很好,但它使用了多个进程(如Apache的prefork)。 HAProxy和nginx是反向代理,似乎没有正向代理function。 鱿鱼很大
这是我的4,继续5小时的问题: 我已经build立了一个WordPress多站点实例,它将在domain.com,subdomain.domain.com和customdomain.com上处理站点。 将有N个网站使用customdomain.com,所以我宁愿不为每个创buildlogging。 在服务器上,我有Nginx在Apache面前。 我想要做的是在Nginx中设置一个通配符logging来处理所有的自定义域。 现在,它看起来像这样: server { listen 80; server_name _; root /home/server_user/web/production; client_max_body_size 50M; client_body_buffer_size 128k; location / { access_log off; proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $proxy_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 通过这个设置,它将把请求传递给Apache,并为dynamic内容提供服务,但是为所有静态内容返回404。 如果我将“server_name”更改为“customdomain.com”,Nginx会再次开始提供静态内容。 当我将“server_name”更改为“_”或者任何其他的catch-all模式时,Nginx就落在了它的面前。 有任何想法吗?
由于我的疏忽,我把http://www.domain.com:8080/xxx/index.html放在网上。 我不想失去stream量,所以我想永久redirect该urlhttp://www.domain.com/xxx/index.html Nginx可以实现这一目标吗? 谢谢
我有一个坐在运行Web应用程序的Jetty Java应用程序服务器前面的nginx web服务器。 如果代理Jetty服务器closures,我想configurationnginx返回一个HTTP 503。 这样,当我将应用程序服务器closures以进行维护时,如果发生故障,503会返回给任何客户端,让他们知道该站点暂时不可用。 但是,使用基本configuration,当Nginx无法连接到proxy_pass位置时,会返回HTTP 502 Bad Gateway。 有没有可能configurationnginx报告一个503呢?
我正在运行一个Django应用程序,在nginx后面使用uWsgi。 我一直在使用ApacheBench进行一些性能调优和负载testing,并且发现了一些意想不到的东西,不知有人能为我解释。 在我的Nginxconfiguration中,我有一个rewrite指令,它可以捕获很多不同的URL排列,然后将它们转发到我希望使用的规范URL,例如,它可以捕捉www.mysite.com/whatever,www.mysite.co.uk/whatever并转发给http://mysite.com/whatever 。 如果我用任何一个redirectURL(即不是最终转发的规范URL)加载testing,它可以服务15000个并发连接,而不会出汗。 如果我加载testing反对规范的URL,上面的testing,我会期望得到转发到任何地方,它不能处理的差不多。 在15000个请求中将会减less4000个,只能可靠地处理9000个。 这是我用来testing的命令行: ab -c15000 -n15000 http://www.mysite.com/somepath/ 和 ab -c15000 -n15000 http://mysite.com/somepath/ 我已经尝试了几种不同的types – 这与我做它们的顺序没有什么不同。这对我来说没有任何意义 – 我可以理解为什么涉及redirect的请求可能无法处理太多的并发连接,但是正在发生另一边。 谁能解释一下? 如果规范的URL可以处理更多的stream量,我真的更喜欢它。 我将在下面发布我的Nginxconfiguration。 感谢加载任何帮助! server { server_name www.somesite.com somesite.net www.somesite.net somesite.co.uk www.somesite.co.uk; rewrite ^(.*) http://somesite.com$1 permanent; } server { root /home/django/domains/somesite.com/live/somesite/; server_name somesite.com somesite-live.myserver.somesite.com; access_log /home/django/domains/somesite.com/live/log/nginx.log; location / { uwsgi_pass unix:////tmp/somesite-live.sock; include uwsgi_params; […]
我们有一个运行PHP-FPM和NGINX的网站。 应用程序向使用40个字符的随机string键入的网站成员发送邀请(仅限字母数字 – 下面的示例)。 今天我们第一次遇到这个问题。 以下url: http://oursite.com/notices/response/approve/1960/OzH0pedV3rJhefFlMezDuoOQSomlUVdhJUliAhjS 正在返回一个404错误。 这种url格式已经工作了6个月,现在没有问题,其他url继续正确parsing。 我们有一个非常基本的configuration,一个简单的redirect到一个前端控制器,其他一切现在已经运行良好。 另外,如果我们将最后一个字符从“S”改为小写“s”以外的任何字符,404错误并且站点正确地处理请求,所以我想知道是否有某个安全模块可能会看到错误的具体string…不知道这是否有道理。 我们不确定在哪里寻找具体是什么导致问题,所以任何方向将不胜感激。 谢谢! 更新:在URL的末尾添加一个斜线,可以正确处理它…仍然希望能够深入到问题的底部。 解决:问题是由我的configuration的一部分引起的…意识到我应该张贴,但是出城,没有机会。 任何以“css”或“js”结尾并且不一定以点为前缀的URL(例如, http://site.com/response/somerandomestringcss )被解释为对文件的请求,并且请求是不通过前端控制器路由。 问题是我的正则expression式禁用日志logging,并在jpgs,gifs,icos等设置过期标题 我replace了这个: location ~* ^.+(jpg|jpeg|gif|css|png|js|ico)$ { 有了这个: location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ { 而现在以css,js,png等结尾的url都是通过前端控制器正确路由的。 希望能帮助别人。