我正在重组网址结构.我需要为特定网址设置重定向规则 - 我正在使用NGINX.
基本上是这样的:
http://example.com/issue1 --> http://example.com/shop/issues/custom_issue_name1
http://example.com/issue2 --> http://example.com/shop/issues/custom_issue_name2
http://example.com/issue3 --> http://example.com/shop/issues/custom_issue_name3
Run Code Online (Sandbox Code Playgroud)
谢谢!
我将Puma作为上游应用服务器运行,将Riak作为后台数据库集群运行.当我发送一个请求map - 减少大约25K用户的数据块并将其从Riak返回给应用程序时,我在Nginx日志中收到错误:
上游超时(110:连接超时),同时从上游读取响应头
如果我在没有nginx代理的情况下直接查询我的上游,使用相同的请求,我会得到所需的数据.
一旦放入代理,就会发生Nginx超时.
**nginx.conf**
http {
keepalive_timeout 10m;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
include /etc/nginx/sites-enabled/*.conf;
}
**virtual host conf**
upstream ss_api {
server 127.0.0.1:3000 max_fails=0 fail_timeout=600;
}
server {
listen 81;
server_name xxxxx.com; # change to match your URL
location / {
# match the name of upstream directive which is defined above
proxy_pass http://ss_api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cloud;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 …Run Code Online (Sandbox Code Playgroud) 我有一个nginx运行实例,它服务于几个网站.第一个是服务器IP地址上的状态消息.第二个是管理控制台admin.domain.com.这些工作很棒.现在我想要所有其他域请求转到单个index.php- 我有很多域和子域,并且在nginx配置中列出它们是不切实际的.
到目前为止,我已经尝试设置server_name到*,但未能作为一个无效的通配符.*.*直到我添加其他服务器块,然后我猜它与它们冲突.
有没有办法在定义其他网站后在nginx中运行catch-all服务器块?
NB我不是垃圾邮件发送者,这些是真正的有用内容的网站,它们只是来自数据库中的相同CMS!
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
#root /usr/share/nginx/www;
root /home/ubuntu/node-login;
# Make site accessible from
server_name ec2-xx-xx-xxx-xxx.us-west-1.compute.amazonaws.com;
location /{
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)
}
这导致nignx错误[警告]冲突的服务器名称"ec2 ..."在0.0.0.0:80忽略我不明白,任何解释赞赏.谢谢.
我在Docker容器上安装了Nginx,我试图像这样运行它:
docker run -i -t -p 80:80 mydockerimage /usr/sbin/nginx
Run Code Online (Sandbox Code Playgroud)
问题在于Nginx的工作方式是初始进程立即产生一个主Nginx进程和一些工作者,然后退出.由于Docker只监视原始命令的PID,因此容器停止.
如何防止容器停止?我需要能够告诉它绑定到第一个子进程,或者阻止Nginx的初始进程退出.
将大于10MB的文件发布到AWS Elastic Beanstalk上运行的API时,我遇到"413 Request Entity Too Large"错误.
我做了很多研究,并且相信我需要为Nginx 启动client_max_body_size,但是我似乎无法找到有关如何使用Elastic Beanstalk执行此操作的任何文档.我的猜测是需要使用ebetension文件进行修改.
任何人都有关于如何达到极限的想法?10MB非常弱,必须有一种方法可以手动启动它.
nginx amazon-ec2 amazon-web-services amazon-elastic-beanstalk
upstream apache {
server 127.0.0.1:8080;
}
server{
location ~* ^/service/(.*)$ {
proxy_pass http://apache/$1;
proxy_redirect off;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码片段会将url包含字符串"service"的请求重定向到另一台服务器,但它不包含查询参数.
我使用Nginx作为反向代理,接受请求,然后执行proxy_pass从端口8001上运行的上游服务器获取实际的Web应用程序.
如果我去mywebsite.com或做一个wget,我会在60秒后获得504网关超时...但是,如果我加载mywebsite.com:8001,应用程序会按预期加载!
因此有些事情阻止了Nginx与上游服务器的通信.
所有这一切都是在我的托管公司重置机器运行之后开始的,之前没有任何问题.
这是我的vhosts服务器块:
server {
listen 80;
server_name mywebsite.com;
root /home/user/public_html/mywebsite.com/public;
access_log /home/user/public_html/mywebsite.com/log/access.log upstreamlog;
error_log /home/user/public_html/mywebsite.com/log/error.log;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Run Code Online (Sandbox Code Playgroud)
我的Nginx错误日志输出:
2014/06/27 13:10:58 [error] 31406#0: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: xxx.xx.xxx.xxx, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:8001/", host: "mywebsite.com"
Run Code Online (Sandbox Code Playgroud) 当我在Ubuntu服务器上的命令行上重新启动nginx服务时,当nginx配置文件出错时,服务崩溃.在多站点服务器上,这会放下所有站点,甚至是没有配置错误的站点.
为了防止这种情况,我首先运行nginx配置测试:
nginx -t
Run Code Online (Sandbox Code Playgroud)
测试成功后,我可以重启服务:
/etc/init.d/nginx restart
Run Code Online (Sandbox Code Playgroud)
或者只重新加载nignx站点配置而不重启:
nginx -s reload
Run Code Online (Sandbox Code Playgroud)
有没有办法将重启命令有条件的那两个命令组合到配置测试的结果中?
我在网上找不到这个,关于此的官方文档是相当基本的.我不太了解Linux,所以我不知道我正在寻找的是在我面前还是根本不可能.
我正在使用nginx v1.1.19.
经过10多个小时的研究,我还没弄清楚为什么这不起作用!我正在尝试将我的localhost移动到我的启用站点的文件夹,该文件夹位于/ etc/nginx/sites-enabled/default中.
它是来自sites-available文件夹的符号链接.使用以下配置时,我使用localhost:8080作为我的地址"无法连接"
nginx.conf(/usr/local/nginx/conf/nginx.conf):
user www-data;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*;
}
Run Code Online (Sandbox Code Playgroud)
sites-available(/ etc/nginx/sites-available/default):
server {
listen 8080;
root /home/myusername/myown/customdirectory;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ …Run Code Online (Sandbox Code Playgroud) nginx ×10
amazon-ec2 ×1
catch-all ×1
command-line ×1
docker ×1
linux ×1
parameters ×1
proxypass ×1
puma ×1
rewrite ×1
server-name ×1
timeout ×1
ubuntu ×1