Tag Archives: nginx

Routing requests through index.php with nginx [closed]

Questions: I’m migrating my server from Apache to Nginx and have this very simple .htaccess rule: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] The idea behind it is to direct every request to a front controller (index.php). I’m trying to do the same with Nginx. I used an online converter to make this… Read More »

How to run Nginx with Node.js on Windows?

Questions: I want to install Nginx on Windows, and to run two node application. How can I do this? I’ve tried to download Nginx 1.6.3, but I don’t find something relevant about how to run on Windows. Just for Linux. I think there should be some modules for node. Any advice will be useful! Answers:… Read More »

Nginx trying to log to /var/logs instead of /var/log?

Questions: I noticed when I test my nginx config using nginx -t, it gives me a warning: nginx: [alert] could not open error log file: open() “/var/logs/nginx/error.log” failed (2: No such file or directory) Which makes sense, since the log path for nginx is actually set up to be /var/log/nginx/ not /var/logs/nginx. I scanned the… Read More »

Nginx WebSocket Reverse Proxy Limitations

Questions: I’ve set up a Nginx Reverse Proxy that uses WebSocket connections and recently began benchmarking the setup with Apache JMeter. Whenever I would make over 600 requests, JMeter would return an error for some of the requests. I individually tested each back-end web-server (with WebSockets) and no request errors appeared until around 11000 requests.… Read More »

What is the point of nginx when I have Kubernetes?

Questions: As I’m going through Docker/Kubernetes tutorials, I notice a lot of people put nginx into a pod. Even after reading about nginx, I am not sure what they are using it for. Doesn’t Kubernetes serve your app and handle things like load balancing and whatnot? Isn’t something like Node.js a “web server” that can… Read More »

docker compose: rebuild of one linked container breaks nginx's upstream

Questions: I’m using docker-compose with “Docker for Mac” and I have two containers: one NGINX, one container serving a node-app on port 3000. docker-compose.yml looks like this: version: “2” services: nginx: build: ./nginx ports: – “80:80” links: – api api: build: ./api volumes: – “./api:/opt/app” In the NGINX’s config I say: upstream api { server… Read More »

How to enable CORS in Nginx proxy server?

Questions: As my title, here is the config file located in conf.d/api-server.conf server { listen 80; server_name api.localhost; location / { add_header ‘Access-Control-Allow-Origin’ ‘http://api.localhost’; add_header ‘Access-Control-Allow_Credentials’ ‘true’; add_header ‘Access-Control-Allow-Headers’ ‘Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range’; add_header ‘Access-Control-Allow-Methods’ ‘GET,POST,OPTIONS,PUT,DELETE,PATCH’; if ($request_method = ‘OPTIONS’) { add_header ‘Access-Control-Max-Age’ 1728000; add_header ‘Content-Type’ ‘text/plain charset=UTF-8’; add_header ‘Content-Length’ 0; return 204; } proxy_redirect off; proxy_set_header host… Read More »