标签: server-configuration

nginx - 基于请求的标头的响应

我安装了nginx 1.0.8.这是我的问题:我有2个文件:file1.jsfile2.js.请求的路径是这样的:

www.mysite.com/files_dir/%user%/file.js

如果请求的标题:" X-Header "存在且值为" OK ",则响应的内容应为file1.js else file2.js.

这些文件位于" html/files_dir "中,%user%是一组目录,表示通过我的服务注册的用户名.

如何在nginx中配置?我对php,asp或类似技术不感兴趣只有在nginx可能的情况下才有意义.

谢谢

server-configuration nginx

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

如何使用位置正则表达式通过nginx重定向/处理来自搜索引擎的请求

我开发了一个基于ajax的web应用程序,带有哈希爆炸网址.

我试图将请求从搜索引擎重定向到另一个生成HTML快照并发送响应的服务器.我试图在nginx中使用location指令实现这一点,如下所述:

      location ~ ^(/?_escaped_fragment_=).*$ {
         proxy_set_header        Host $host;
          proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header        X-Forwarded-Proto $scheme;

          client_max_body_size    10m;
          client_body_buffer_size 128k;
          proxy_connect_timeout   60s;
          proxy_send_timeout      90s;
          proxy_read_timeout      90s;
          proxy_buffering         off;
          proxy_temp_file_write_size 64k;
          proxy_pass      http://x1.x2.x3.x4:8080;
          proxy_redirect      off;
      }
Run Code Online (Sandbox Code Playgroud)

但我无法让这个工作.有人可以纠正我正在使用的正则表达式(或)为我提供替代解决方案来实现这一目标.

提前致谢.

server-configuration web-applications nginx

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

Apache配置中每个子连接最大连接数的建议最大值是多少?

我正在努力减少Apache在服务器上的内存使用量.

我实际每个孩子的最大连接数是10k

根据以下建议

每个孩子的最大连接数应减少到1000

http://www.lophost.com/tutorials/how-to-reduce-high-memory-usage-by-apache-httpd-on-a-cpanel-server/

Apache配置中每个子连接最大连接数的建议最大值是多少?

apache connection server-configuration

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

Apache 2.4 如何仅对特定主机要求有效用户

如果主机是 dev.example.com 或 test.example.com,我想告诉 Apache 2.4.9 要求有效用户。这不起作用:

AuthType Basic
AuthName "Speak, friend, and enter."
AuthBasicProvider file
AuthUserFile /sites/example/conf/.htpasswd
AuthGroupFile /dev/null
SetEnvIfNoCase Host ^dev\.example\.com$ env_is_protected
SetEnvIfNoCase Host ^test\.example\.com$ env_is_protected
Require valid-user
Require not env env_is_protected
Run Code Online (Sandbox Code Playgroud)

它会导致服务器错误;显然与文档相反not env是无效

在以下示例中,前五行始终与第一个示例中的相同。

这不起作用:

SetEnvIfNoCase Host ^dev\.example\.com$ env_is_protected
SetEnvIfNoCase Host ^test\.example\.com$ env_is_protected
<RequireAny>
    Require valid-user
    <RequireNone>
        Require env env_is_protected
    </RequireNone>
</RequireAny>
Run Code Online (Sandbox Code Playgroud)

它会导致服务器错误。该文档解释

因为否定授权指令无法返回成功的结果,所以它们不能显着影响 <RequireAny> 指令的结果。(在它们失败并且所有其他指令返回中性值的情况下,它们最多可能导致指令失败。)因此,在 <RequireAny> 指令中不允许使用否定授权指令。

这不起作用:

SetEnv env_is_unprotected 1
SetEnvIfNoCase Host ^dev\.example\.com$ !env_is_unprotected
SetEnvIfNoCase Host ^test\.example\.com$ !env_is_unprotected …
Run Code Online (Sandbox Code Playgroud)

apache .htaccess server-configuration httpd.conf basic-authentication

4
推荐指数
1
解决办法
5469
查看次数

Errno::EACCES(权限被拒绝@dir_s_mkdir

我在带有 nginx/passenger/WebRick/ 的 Ubuntu 14.04 服务器中的rails 应用程序上部署了我的ruby(使用 rbenv),当我在生产环境中运行服务器时,该站点完美呈现,没有任何问题,但是当我退出 ssh 连接时,网站呈现空白,没有错误,只是一个空白的白页。

当我重新建立 ssh 连接时,即登录到服务器,我完全获得了页面!

日志,给了我这个错误,

Errno::EACCES(权限被拒绝@dir_s_mkdir - /home/username/appname)

错误日志截图:
http : //postimg.org/image/iolw2rwdr/
http://postimg.org/image/phsel5skd/

server-configuration ruby-on-rails passenger nginx ruby-on-rails-4

4
推荐指数
1
解决办法
3846
查看次数

nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)

我有一个简单的 django 网站,我正在尝试加载 nginx 和 uwsgi 。

当我尝试测试我的 nginx 配置时,我得到以下信息:

$ sudo nginx -t
nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)

我的站点可用/默认配置如下所示:

# the upstream component nginx needs to connect to
upstream django {
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve …
Run Code Online (Sandbox Code Playgroud)

django server-configuration nginx uwsgi

4
推荐指数
1
解决办法
4526
查看次数

无法在端口1433上打开与主机的连接:连接失败

今天我安装了SQL Server.我试图从SQL Server的应用程序连接.但连接失败了.我试图telnet到以下

telnet 127.0.0.1 1433
Run Code Online (Sandbox Code Playgroud)

但是我得到了以下信息:

在此输入图像描述

注意:我试图ping它是成功的.

我需要信息在SQL Server上启用端口号1433.我正在使用SQL Server 2008客户端(管理工作室)和SQL Server 2008 Express引擎.

谢谢

port server-configuration sql-server-2008

3
推荐指数
1
解决办法
2万
查看次数

Laravel Nginx 查询字符串参数

我正在使用 Laravel 5.2 和 Nginx,并且在我的开发服务器上运行良好。

例如:

http://example.com/results?page=2
Run Code Online (Sandbox Code Playgroud)

开发服务器

LengthAwarePaginator::resolveCurrentPage(); // returns 2
Paginator::resolveCurrentPage(); // returns 2
$request->input('page'); // returns 2
Run Code Online (Sandbox Code Playgroud)

但是在生产服务器中

LengthAwarePaginator::resolveCurrentPage(); // returns 1
Paginator::resolveCurrentPage(); // returns 1
$request->input('page'); // returns null
Run Code Online (Sandbox Code Playgroud)

生产服务器配置

server {
        listen 80 ;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html/laravel/public;
        index  index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name example.com www.example.com;

        location / {
                try_files $uri $uri/ /index.php;
        }

        location @rewrite {
            rewrite ^(.*)$ /index.php?_url=$1;
        }

        location ~ \.php$ {
                try_files $uri $uri/ …
Run Code Online (Sandbox Code Playgroud)

php server-configuration nginx query-parameters laravel

3
推荐指数
1
解决办法
3538
查看次数

在 Azure SQL 数据库中找不到 sp_configure?

我需要 sp_configure 来在 MS SQL 中运行 R 脚本。但每当我尝试运行“ EXECUTE sp_configure ”或“ exec sp_execute_external_script ”之类的内容时,它都会说“找不到存储过程“sp_configure”。' 和'sp_execute_external_script' 失败,因为此 SQL Server 实例 'A5DC0B2838AC' 的版本不支持它。有关不同 SQL Server 版本中功能支持的更多详细信息,请参阅在线书籍。'

我什至尝试创建系统存储过程 sp_config 但在过程“ EXEC %%ServerConfiguration( ConfigID = @confignum ).SetValue( Value = @configvalue ) ”的这一行出现错误,并且错误是“%”附近的语法不正确

sql-server server-configuration r azure-sql-database

3
推荐指数
1
解决办法
7756
查看次数

Symfony3 在登录时立即丢失用户会话

我将我的 Symfony3 应用程序从共享主机移到了我刚刚设置的新 VPS。当我尝试登录应用程序(使用随意的 FOSUserBundle 表单)时,Symfony 确实登录我只是为了在下一页重新加载时断开我的连接。这是“立即”,因为成功登录所做的第一件事就是重定向到一个页面。

我试过的:

  • 我禁用了重定向,这使我可以在“login_check”页面上看到我已连接。我知道这一点,因为 Symfony 调试工具栏显示了我的名字。只有在重定向后不再。
  • 我可以随时随地看到我的 cookie 中没有 PHPSESSID。我认为它是负责保持我的 Symfony 会话活跃的 cookie。所以...
  • 我尝试了不同的 php 脚本来检查我的 VPS 配置。它确实可以很好地处理 cookie 和 PHP 会话。
  • 我什至在子文件夹中安装了 Wordpress,它可以完美地处理我的会话和 cookie。
  • Symfony 用于存储会话的服务器文件夹与 Wordpress 使用的相同。并且会话文件确实出现在 Symfony 登录尝试中。(虽然有时它们只是空文件......!?)
  • 将 FOSUB 和 Symfony 升级到最新版本。没有变化。

我正在使用 Symfony 3.4.6 和 FOSUB 2.0.0。任何的想法?

更新:Security.yml

# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
    fos_userbundle:
        id: fos_user.user_provider.username_email

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            check_path:     fos_user_security_check
            failure_path:   fos_user_security_login
            login_path: /fr/public/login
            default_target_path: app_homepage
        logout:
            path: fos_user_security_logout
            target: fos_user_security_login
        anonymous:    true


access_control:
    # Allow anonymous …
Run Code Online (Sandbox Code Playgroud)

php server-configuration symfony fosuserbundle symfony-3.4

2
推荐指数
1
解决办法
1562
查看次数