我是linux + nginx的新手。 我已经安装了nginx,并试图在〜/ sites-available / default文件中做一些修改,但忘了备份这个文件。 所以,现在我得到以下错误: nginx:[emerg]“server”指令在/ etc / nginx / sites-available / default中是不允许的:16 nginx:configuration文件/ etc / nginx / sites-available / default test failed 请告诉我错误在哪里。 这里是默认文件: ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the […]
在nginx中使用try_files时,是否有一种方法可以在try_files指令中指定每个URI之后才指定和使用自定义的error_page? 以下configuration不起作用: location / { if (-f $document_root/error_page.html ) { error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 495 496 497 500 501 502 503 504 505 506 507 /error_page.html; } try_files $uri $uri/ @redirect_store; } 看起来如果你使用error_page指令,当nginx找不到传入的URI时,它立即返回自定义的404错误页面,而不是尝试try_files中的下一个条目。 看来,error_page指令覆盖try_files? 我只能得到这个工作,当没有指定error_page指令: location / { try_files $uri […]
我试图在本地或从一个分享(本地刷新过夜)图片。 我的nginx站点服务于2个或更多的服务器,以保持所有内容在每个服务器同步,我将它存储在一个Azure文件共享,这是位置根(/ mnt / wp)。 这工作得很好(与Nginxcaching一起),但是图像的等待时间非常缓慢,我认为这是一个延迟问题client-server-azure。 所以为了让事情更快,我想在本地提供图像(/ var / www /),如果可用的话,然后回落到azure(/ mnt / wp) 到目前为止,我有这个位置块,但日志显示redirect循环.. 我错过了什么吗? location /wp-content/ { add_header X-uploads $uri; try_files @contentCache/$uri $uri; } location @contentCache{ root /var/www; }
我试图在一台机器上设置多个具有相同映像的docker容器,并将所有应用程序托pipe在由path分隔的同一个域中。 目的是将每个客户分离到自己的容器中。 即mydomain.com/bbb …等 我正在使用nginx作为反向代理,并在线上跟随各种示例。 我的nginxconfiguration如下所示: server { listen …; … location / { proxy_pass http://127.0.0.1:8080; } location /aaa { proxy_pass http://127.0.0.1:8181; } location /bbb { proxy_pass http://127.0.0.1:8282; } … } 我注意到,应用程序正在期待被托pipe在根目录/目前在404结束了。有没有一种聪明的方法来重写这些到自己的path基于请求的来源而不修改应用程序本身? 我知道,使用子域名可能更容易,但是我想避免在客户来去时添加和删除子域名。
我的nginx设置需要将所有非/api/请求http://198.xxx.xxx.xx:8080/到http://198.xxx.xxx.xx:8080/ 。 当我访问/ ,一切都很好。 我可以访问我的前端提供的任何路线。 但是,当我刷新,路线没有find。 我意识到我可以将每个路由手动添加到根目录的proxy_pass 。 显然这将是乏味的。 必须有一个错误或更好的方式来configuration我的nginx设置。 这是我的设置: upstream app_server { server unix:/var/run/unicorn.sock fail_timeout=0; } server { listen 80; server_name xxxxxxxxxxxxxxxx.com; location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ { try_files $uri @app; } location ^~ /api/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwaded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server/api/; } location /about { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For […]
我正在运行安装了VestaCP的VPS。 Web面板在端口8083上运行。 我已经设法得到它在panel.domain.com工作,但是,面板中的一些URL在使用子域时会失去function。 我想知道如何让端口8083指向domain.com/panel 。 这是我在我的nginxconfiguration中尝试过的: server { listen 108.xx.xx.xxx:443; server_name domain.com; root /var/www/ghost; index index.html index.htm; location /panel { proxy_pass https://127.0.0.1:8083; } }
我想在ec2中的nginx / django上使用ssl。 这是configuration server { listen 443; ssl on; ssl_certificate /apps/cert-chain.crt; ssl_certificate_key /apps/private.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; server_name mytest.com; location /static { alias /apps/static/; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 75s; proxy_connect_timeout 75s; if (!-f $request_filename) { proxy_pass http://127.0.0.1:9006; break; } } } 在启动nginx时出现以下错误 nginx: […]
我已经尝试了其他职位的无数解决scheme,但似乎没有为我工作,我总是得到一个404错误,当试图让nginx服务我的flask应用程序的静态文件。 在所有这些试图让它运行的尝试之间,我也有一个403 ,但我不能重build它。 这是我目前的设置: 该应用程序位于: ~/development/Python/flask_nginx_gunicorn/ ,应该是一个运行的testing项目,了解nginx等等。 它有以下结构: 所以没有什么比一个名为app.py的文件,它在static文件夹中configuration了几条path和一个index.html 。 我configuration我的nginx如下: /etc/nginx/nginx.conf包含以下内容: user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; […]
你好,我正在尝试redirect所有的请求使用https。 我创build了一个侦听端口80(http)的服务器块,我想redirect用户使用https://但我不确定如何获取主机名。 这是我的服务器块 server { listen 80; server_name : *.example.org return 301 https://{{hostname}}$request_uri } 我知道URI是由$request_uri访问,但我不确定如何获取主机名。 你们把他们附在一起,没有空间吗?
我为我的GoDaddy域设置了一个DNS掩码,以便我的Amazon EC2 url不会显示给用户。 用户现在可以用一些GoDaddy的东西包装它,而不是由Nginx返回的原始index.html: <head> <title>My Home</title> <META name="description" content="Blah blah."><META name="keywords" content="Blah, blah"> </head> <frameset rows="100%,*" border="0"> <frame src="http://ec2-xx-xxx-xxx-xx.us-west-2.compute.amazonaws.com" frameborder="0" /> <frame frameborder="0" noresize /> </frameset> 最终的问题是,这似乎打破了原来的index.html我的HTML元视口设置和页面不正确地呈现在移动设备上。 当然,设置仍然在某个地方,但浏览器似乎忽略它可能是由于框架的事情。 我怎样才能解决这个问题? 我不知道我是否正确地做这个设置,因为我是这个东西的完全新手:)