nginx-config

Run multiple django project with nginx and gunicorn

别说谁变了你拦得住时间么 提交于 2020-01-01 03:24:26
问题 I am using Ubuntu 18 servers and using nginx with gunicorn I follow Digitalocean tutorial for server setup. I successfully did for one project but now I need to run multiple projects under by server. Here is my gunicorn setup command: sudo nano /etc/systemd/system/gunicorn.service file: [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] User=rfr Group=www-data WorkingDirectory=/home/rfr/helpdesk/helpdesk ExecStart=/home/rfr/helpdesk/env/bin/gunicorn \ -

nginx is serving pages for requests for bare IP address (which doesn't match the server_name)

烈酒焚心 提交于 2019-12-13 04:25:04
问题 I have an nginx configuration with two virtual hosts and no default site. server { listen 123.45.67.89:80; server_name site_a.example.com site_a1.example.com; root /srv/site_a_checkout/html/site_a; access_log /var/log/site_a/nginx.access.log; error_log /var/log/site_a/nginx.error.log; index index.html index.htm index.nginx-debian.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } } Each of the

How to insert read path in try_files? Rewrite Error in Nginx

萝らか妹 提交于 2019-12-13 03:56:24
问题 A redirect was created for when returning "404" and go to the first directory of the URL, ex: foo.com.br/air/uknwfileerror > foo.com.br/air But this is not working just for .php extension foo.com.br/air/uknwfileerror.php > foo.com.br/air listen *:443; server_name portal-dev.foo.com.br ; root /var/www/novo; ssl_session_cache shared:SSL:20m; ssl_session_timeout 20m; resolver 1.1.1.1; set $proxy_foops_https 'https://proxy-portal-dev-stg.foo.com.br'; set $proxy_foops_http 'http://proxy-portal-dev

NginX GeoIP Module Config - load_module not allowed on First Line of Conf

天大地大妈咪最大 提交于 2019-12-12 18:22:40
问题 My nginx conf looks like this: include /usr/share/nginx/modules/mod-http-geoip.conf; server { } server { } I had installed mod-http-geoip via sudo yum install nginx-mod-http-geoip and i have these: /usr/share/nginx/modules/mod-http-geoip.conf: load_module "/usr/lib64/nginx/modules/ngx_http_geoip_module.so"; /usr/lib64/nginx/modules/ngx_http_geoip_module.so The error I get: 2018/07/09 09:37:14 [emerg] 9552#0: "load_module" directive is not allowed here in /usr/share/nginx/modules/mod-http

Nginx Configuration with Static Files under Django

元气小坏坏 提交于 2019-12-11 18:26:30
问题 I am setting an Nginx configuration with my Django project. In order to provide some static file without /static/ showing on the URL, I add some rewrite rules in Nginx configuration. Here is part of my Nginx configuration: location /static/ { location ~* \.(png|jpg|jpeg|gif|css|js)$ { access_log off; expires 30d; } alias /path/to/myproject/static/; } location ~ ^/favicon.ico$ { rewrite ^/favicon.ico$ /static/favicon.ico; } location /foo/ { rewrite ^/foo/(.*)$ /static/abc/$1; } location /bar/

nginx configuration to provide dynamic error pages

安稳与你 提交于 2019-12-11 09:03:15
问题 I have an nginx server setup that serves as is used to for proxy and serving static content. The static contents are based on multiple react apps. What I want to do is replace the default error pages from nginx and serve the error pages from a React App. The React app handles error pages based on the url. http://localhost/401.html will provide the standard 401 HTTP error page for the app, and so on. The problem is how to correctly configure this in nginx, because in reality there is no 401

How to configure nginx as proxy_pass?

天大地大妈咪最大 提交于 2019-12-11 08:49:20
问题 I have use Certbot Nginx to install my nginx to Ubuntu 18.04. I also use Certbot to get the LetsEncrypt certificate. I use basic configuration such as use tcp 80 and 433 so I can get both http and https. Most of the configuration done by Certbot. my domain is http://example.com and provides static page. Bu I also have a folder and I can call it with http://example.com/myfolder. After I install nginx I try to use proxy_pass and https to my local rest_api services. If I type http://127.0.0.1

Can't adjust redirect in Nginx, for message with code 401 “Auth Required”

﹥>﹥吖頭↗ 提交于 2019-12-11 06:32:14
问题 I can't adjust redirect in Nginx virtual hosts config-file, specifically for "401 error message" (401 Authorization Required). My target: When I open address in web-browser, for example it'll be my.domain.com, I want adjust basic authentication and I wanna get custom html page with original design and original login form instead of simple browser window. screen shot So, for this realisation need adjust redirect on 401 message to my custom page. I did try it like this, but it doesn't gave to

Nginx bypass cache if upstream is up and use cache if down

妖精的绣舞 提交于 2019-12-11 06:19:53
问题 To bypass cache if upstream is up (max-age 1) and use cache if down (proxy_cache_use_stale) I created following config: proxy_cache_path /app/cache/ui levels=1:2 keys_zone=ui:10m max_size=1g inactive=30d; server { ... location /app/ui/config.json { proxy_cache ui; proxy_cache_valid 1d; proxy_ignore_headers Expires; proxy_hide_header Expires; proxy_hide_header Cache-Control; add_header Cache-Control "max-age=1, public"; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;

Kubernetes Ingress Nginx loading resources 404

孤街浪徒 提交于 2019-12-08 19:10:48
问题 Hy We're trying to get our website working on kubernetes (running in a container using nginx). We use ingress to route to the site, here is our configuration: nginx-conf: server { listen 80; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html =404; } } Kubernetes deployment: apiVersion: apps/v1beta1 kind: Deployment metadata: name: mywebsite spec: replicas: 2 template: metadata: labels: app: mywebsite spec: containers: - name: mywebsite image: