我有一个域,叫它example.com,与path/ test1和/ test2。 http example.com/test1的请求被送到test1.example.com/test1。 http example.com/test2的请求被送到test2.example.com/test2。 这个nginxconfiguration对我的要求工作得很好。 server { listen 80 default_server; root /usr/share/nginx/html; server_name localhost; index index.html; autoindex on; location /test1 { resolver ns1.example.com; resolver_timeout 5s; proxy_pass http://test1.example.com/test1; proxy_redirect default; } location /test2 { resolver ns1.example.com; resolver_timeout 5s; proxy_pass http://test2.example.com/test2; proxy_redirect default; } } 我现在需要改变configuration,如果可能的话,请求将其设置到适当的后端,而不是单独添加到nginxconfiguration。 使用子域而不是path是一个长期的select,但由于其他约束在这个时候不可行。 我宁愿将解决scheme包含在nginxconfiguration中,而不是依靠维护当前example.com主机名的数据库(如果可能的话)。 uripath中的第一个斜杠之后和第二个之前(如果存在)的数据是我需要键入的。 例如:example.com/debug/index.html。 debugging将被parsing出来。 在example.com域中debugging可能是也可能不是有效的主机名。 如果它是无效的(404,500,或502错误..也许其他),然后下降到一个全面的页面。 如果有效,请将请求指向debug.example.com/debug/index.html。 […]
我们制作了一个应用程序,需要每天为每个用户下载数百个图像。 我们的基本服务器设置如下:Loadbalancer – > Nginx – > Databaseserver 但是,我们的应用程序“随机”滞后。 它似乎与磁盘I / O有关系。 每当它出现尖峰,应用程序滞后。 这里有一些图像来显示问题。 什么可以导致这个? 而最重要的是: 我该如何解决这个问题? 我真的不知道从哪里开始。 任何帮助是极大的赞赏! 🙂
我是1)寻找如何pipe理和2)跨不同环境testing复杂nginxconfiguration的想法。 目前我将Nginxconfiguration存储在github仓库中,将环境分隔到不同的目录(dev,test,stage,prod等),并通过include指令重复使用相同的configuration。 要部署正确的configuration,我正在运行一个简单的脚本来复制到所有正确的configuration,但我开始遇到扩展问题,因为configuration变得越来越复杂,更多的环境被添加到回购。 有没有一个好的工作stream程或方法来pipe理和testingconfiguration? 我正想着以某种方式模板configuration,但不知道从哪里开始。 是否有任何种类的单元/集成框架来testingNginxconfiguration的单独组件? 比如说,“Nginx是在X端口上听的吗?” 以确保事情不会因为新件被添加到configuration而中断。 我最终希望将这种逻辑添加到某种CI / CD中,以确保事物不被破坏。
我有nginx作为ssl的玻璃鱼服务器的反向代理服务,提供三个glassfish上下文,一个演示站点,一个jenkins和一个glassfishpipe理服务器。 根被redirect到演示站点。 Http被redirect到https,nginx做ssl卸载。 所有的工作都完美地解决了两个问题: 当第一次浏览演示网站(或删除浏览器历史logging后),我得到了glassfish的根,而不被redirect到https。 做一个刷新,我正确地redirect到https演示网站。 当浏览glassfishpipe理员时,我得到一个空白页面,pipe理页面的索引正确加载,但所有资源不加载(404)。 nginx错误日志给我显示以下错误: 2015/11/19 08:27:13 [error] 12656#0: *2 open() "/usr/share/nginx/html/resource/community-theme/images/login-product_name_open.png" failed (2: No such file or directory), client: <ip-address>, server: demo.domain.nl, request: "GET /resource/community-theme/images/login-product_name_open.png HTTP/1.1", host: "demo.domain.nl", referrer: "https://demo.domain.nl/admin/" 任何帮助非常感谢! 下面你可以find我的nginx conf: server { listen 80; listen [::]:80; server_name demo.domain.nl; return 301 https://$server_name$request_uri; } server { listen 443 default ssl; […]
我刚刚在基于Debian Jessie的nginx 1.8.0 webserver上启用了IPv6。 要做到这一点,我编辑了我的虚拟主机configuration: server { listen 80; listen [2001:1608:10:160:34::2]:80; server_name dominicpratt.de www.dominicpratt.de; return 301 https://dominicpratt.de$request_uri; } server { listen 443; listen [2001:1608:10:160:34::2]:443; server_name dominicpratt.de www.dominicpratt.de; root /var/www/dominicpratt.de; index index.html index.htm index.php; access_log /var/log/nginx/dominicpratt.de_access.log; ssl on; ssl_certificate /etc/nginx/ssl/dominicpratt.de/combined.pem; ssl_certificate_key /etc/nginx/ssl/dominicpratt.de/wildcard.key; location / { try_files $uri $uri/ /index.php?q=$request_uri; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; […]
我想为nginx设置ssl,我的项目是django,我也使用gunicorn作为wsgi http服务器。 我在settings.py代码中添加以下几行代码: CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True 我不知道是否有必要这样做,然后我configuration我的nginx在以下forms: server { listen 80; server_name <name>; return 301 https://$host$request_uri; } server { #listen 80; listen 443 default ssl; client_max_body_size 4G; server_name <name>; #ssl on; ssl_certificate /etc/nginx/ssl/ssl.crt; ssl_certificate_key /etc/nginx/ssl/ssl.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; keepalive_timeout 5; # path for static files […]
我有一个非常小的configuration,我相信应该反向代理我在example.com:1234上看到example.com[:80] 。 error_log /var/log/nginx/error.log info; events{ } http{ server{ listen 80; server_name example.com; location / { proxy_pass http://example.com:1234; proxy_redirect default; } } } 但是,导航到端口80导致内部服务器错误500 – 导航到端口1234呈现预期的输出。 日志只包含“信号进程开始”条目。 我做错了什么,或错过了? 如何logging服务器错误的更好(任何!)描述; 我预计这不是最后一次有用的。
我的要求 鬼博客www.mydomain.com/blog 根目录中的index.html,contact.php,几个图像和js文件。 (即像www.mydomain.com/index.html,mydomain.com/contact.php等) 阅读本教程之后,我可以运行幽灵在www.mydomain.com/blog上。 但不幸的是,我无法访问根目录,即www.mydomain.com任何东西,因为它会引发404错误 在安装Ghost之前在/usr/share/nginx/www目录下的所有内容都可用。 现在,我用ls命令检查文件是否存在于文件夹/usr/share/nginx/www ,我可以在terminal上查看这些文件。 当我cd到/etc/nginx/sites-available/文件夹时,我可以看到2个文件ghost和default以及/etc/nginx/sites-enabled/我只能看到ghost文件。 当我将/etc/nginx/sites-available/的默认文件复制到/etc/nginx/sites-enabled/ ,Ghost Blog给出了一个404错误。 这里是默认文件内容服务器{listen 80 default_server; 听[::]:80 default_server ipv6only = on; root /usr/share/nginx/html; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying […]
尝试使用nginx正则expression式位置configuration实现url第一段中的常量语言代码,并找不到正确的语法。 必要的结果: example.com 保持 example.com example.com/zh 保持 example.com/en example.com/en/ 保持 example.com/zh 或 example.com/en/(不关心) example.com/en/etc 保留 example.com/en/etc example.com/etc 更改为 example.com/en/etc example.com/etc/segment 更改为 example.com/en/etc/segment 目前我已经发现了这个代码,但它仍然停留在某个地方。 它使永久循环,并不使用$ 1参数。 location ~ "^/(?![az]{2}/)(.+)$" { rewrite / /en/$1 permanent; } #Using handler here for removing index.php in uri (example.com/index.php -> example.com); location / { index index.htm index.html index.php; try_files $uri $uri/ […]
我有以下configuration: upstream ring { server 127.0.0.1:3000 fail_timeout=0; } server { root /home/app/public; index index.dev.html; server_name localhost; location / { try_files $uri $uri/ @ring; } location @ring { proxy_pass http://ring; proxy_set_header Host $http_host; proxy_buffering off; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 它用作文件,然后是目录,然后代理到应用程序服务器。 这按预期工作。 但是现在,我希望在用户第一次访问该网站时将用户redirect到about.html页面。 所以我改变了以下configuration: upstream ring { server 127.0.0.1:3000 fail_timeout=0; } […]