# [[Nginx]] ![[Nginx.svg]] Nginx (_"engine-ex"_) is a type of [[Open source]] web server that is built to handle high concurrency. It was created in 2004 by [[Igor Sysoev]]. ## Nginx performance Nginx was built for low memory and high concurrency, and does so by handling requests asynchronously. Its approach is [[Message-oriented architecture|event-driven]][^01] to allow it to use a single thread to process multiple requests. When comparing it to [[Apache Software Foundation|Apache]], Nginx is the more popular option for high-traffic websites, being the server of choice for 60.9% of the 100,000 most popular sites [^01]. ## Uses for Nginx - web server (original) - reverse proxy - HTTP cache - [[Load Balancer]] ## Structure When Nginx is used as a web server, there are two places that config is held: - `/etc/nginx/sites-available` has all possible configs, but they're not live - `/etc/nginx/sites-enabled` is the place for the configs that *are* live. Config from `sites-available` is [[symlink|symlinked]] to this spot to enable them. The configuration files end in `.conf` and contain what's called [[Setting up server blocks on Nginx|server blocks]]. Each `server { } ` block contains instructions for how to handle requests to a particular resource on a particular port. ## [[Installing Nginx on Ubuntu]] ## [[Setting up server blocks on Nginx]] ## Commands ### Restart Nginx ```bash sudo systemctl restart nginx ``` ### Get status ```bash sudo service nginx status ``` ### View logs ```bash sudo nano /var/log/nginx/error.log ``` ### Test config ```bash nginx -t ``` ## Troubleshooting - [[Can't access sub-URLs on Nginx server]] - [[HTTP 404 on Nginx]] ## See Also - [[Installing an SSL certificate on Nginx server with Let's Encrypt and Certbot]] - [[Setting up Nginx as a reverse proxy]] - [[Recommended practices for initializing a new virtual server]] ## References - https://phoenixnap.com/kb/nginx-reverse-proxy - [[DigitalOcean]]: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04 [^01]: [[What Is Nginx - A Basic Look at What It Is and How It Works]] %% # Excalidraw Data ## Text Elements ## Drawing ```json { "type": "excalidraw", "version": 2, "source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/2.1.4", "elements": [ { "id": "4y8R7iOA", "type": "text", "x": 118.49495565891266, "y": -333.44393157958984, "width": 3.8599853515625, "height": 24, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", "fillStyle": "solid", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "groupIds": [], "frameId": null, "roundness": null, "seed": 967149026, "version": 2, "versionNonce": 939059582, "isDeleted": true, "boundElements": null, "updated": 1713723615080, "link": null, "locked": false, "text": "", "rawText": "", "fontSize": 20, "fontFamily": 4, "textAlign": "left", "verticalAlign": "top", "containerId": null, "originalText": "", "lineHeight": 1.2 } ], "appState": { "theme": "dark", "viewBackgroundColor": "#ffffff", "currentItemStrokeColor": "#1e1e1e", "currentItemBackgroundColor": "transparent", "currentItemFillStyle": "solid", "currentItemStrokeWidth": 2, "currentItemStrokeStyle": "solid", "currentItemRoughness": 1, "currentItemOpacity": 100, "currentItemFontFamily": 4, "currentItemFontSize": 20, "currentItemTextAlign": "left", "currentItemStartArrowhead": null, "currentItemEndArrowhead": "arrow", "scrollX": 583.2388916015625, "scrollY": 573.6323852539062, "zoom": { "value": 1 }, "currentItemRoundness": "round", "gridSize": null, "gridColor": { "Bold": "#C9C9C9FF", "Regular": "#EDEDEDFF" }, "currentStrokeOptions": null, "previousGridSize": null, "frameRendering": { "enabled": true, "clip": true, "name": true, "outline": true } }, "files": {} } ``` %%