小编che*_*ops的帖子

将htaccess转换为nginx

我没有运气将htaccess规则转换为nginx重写.我已经检查了NginxRewriteModule文档,并完成了一些,但更复杂的是我不知所措.这就是我在看的内容:

RewriteRule    ^$                                               /cgi-bin/index.cgi [L]
RewriteRule    ([0-9A-Za-z]{12})-del-([0-9A-Za-z]+)/.+$         /cgi-bin/index.cgi?del=$1-$2 [L]

RewriteCond     %{REQUEST_FILENAME} !-f

RewriteRule    ^([0-9A-Za-z]{12})(\.html?|$)$                   /cgi-bin/index.cgi?op=download1&id=$1 [L]
RewriteRule    ^([0-9A-Za-z]{12})(\/.+|\.html?|$)               /cgi-bin/index.cgi?op=download1&id=$1&fname=$2 [L]
RewriteRule    ^([0-9A-Za-z\-_]{4,64})/([0-9A-Za-z]{12})$   /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2 [L]
RewriteRule    ^([0-9A-Za-z\-_]{4,64})/([0-9A-Za-z]{12})(\/.+|\.html?|$)        /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2&fname=$3 [L]

#RewriteRule    ^Reseller\.html$                                         /cgi-bin/Templates/Pages/english/Reseller.html [L]
RewriteRule    ^checkfiles\.html$                                       /cgi-bin/index.cgi?op=checkfiles [L]
RewriteRule    ^contact\.html$                                          /cgi-bin/index.cgi?op=contact [L]
RewriteRule    ^premium\.html$                                          /cgi-bin/index.cgi?op=payments [L]
RewriteRule    ^login\.html$                                            /cgi-bin/index.cgi?op=login [L]
RewriteRule    ^catalogue(.*)\.html$                                    /cgi-bin/index.cgi?op=catalogue&date=$1 [L]
RewriteRule    ^news([0-9]*)\.html$                                     /cgi-bin/index.cgi?op=news&page=$1 [L]
RewriteRule    ^n([0-9]+)-.*\.html$                                     /cgi-bin/index.cgi?op=news_details&news_id=$1 [L]
RewriteRule    ^free([0-9]+)\.html$                     /cgi-bin/index.cgi?op=registration&aff_id=$1 [L]
RewriteRule    ^users/([0-9A-Za-z\-_]{4,64})/?([0-9]+|$)        /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld_id=$2 [L,NC]
RewriteRule    ^embedmp3-([0-9A-Za-z]{12})\.html$   /cgi-bin/index.cgi?op=mp3_embed&file_code=$1 [L]
RewriteRule    ^embedmp4-([0-9A-Za-z]{12})\.html$   /cgi-bin/index.cgi?op=mp32_embed&file_code=$1 [L]
RewriteRule    ^box$                                    /cgi-bin/index_box.cgi [L] …
Run Code Online (Sandbox Code Playgroud)

.htaccess rewrite nginx

24
推荐指数
3
解决办法
14万
查看次数

开发,登台和生产环境rails app

我正在创建一个应用程序,除了实时生产环境之外,还需要开发和登台环境.生产环境当前处于活动状态并且位于自己的VPS实例上.一个记录:

myapp.com  1.2.3.4
Run Code Online (Sandbox Code Playgroud)

开发和登台环境将在他们自己的VPS实例上.我已配置了相应的DNS记录,因此每个环境都有自己的子域(myapp.com域中的一条记录指向dev/staging服务器:

dev.myapp.com 5.6.7.8
staging.myapp.com 5.6.7.8
Run Code Online (Sandbox Code Playgroud)

Nginx confix(Rails,Passenger)设置每个服务器的根目录(通配符SSL在http定义中配置,端口80重定向到端口443):

server {
   listen 443;
   server_name dev.myapp.com
   root /apps/myapp/dev/public
}

server {
   listen 443;
   server_name staging.myapp.com
   root /apps/myapp/staging/public
}
Run Code Online (Sandbox Code Playgroud)

我在Rails方面有点困惑,我还需要做什么来配置环境,以便我可以通过URL访问各个开发和登台环境:

staging.myapp.com
dev.myapp.com
Run Code Online (Sandbox Code Playgroud)

我知道Capistrano允许您设置生产和登台环境,但我需要开发和登台URL才能生效或者这应该足够吗?

ubuntu ruby-on-rails passenger nginx

5
推荐指数
1
解决办法
2163
查看次数

标签 统计

nginx ×2

.htaccess ×1

passenger ×1

rewrite ×1

ruby-on-rails ×1

ubuntu ×1