Nginx

Related

Nginx服务器反向代理

1. nginx服务器Nginx与Apache为两大主流web服务器。而我的轻量级云服务器使用了nginx。因为nginx相比与apache更轻量,性能更好,不怎么占内存,适合中小型服务器。同时Nginx善于应对高并发场景,在多用户同时点击的情况下,服务器能负荷得住。又由于nginx的负载均衡,让多个用户打开网站没那么卡。nginx官网安装教程Installing NGINX Open Source | NGINX DocumentationDebian12安装nginx:sudo apt-get update sudo apt-get install nginx最后输入sudo nginx -v验证安装。2. Nginx服务器反向代理客户端对代理是无感知的,只需将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据后,再返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器,暴露的是代理服务器地址,隐藏了真实服务器IP地址
2024-05-14 23:53:12

Nginx is installed but command not found

Problem. I installed nginx on my Debian 12 server following the steps in the official documentation Installing NGINX Open Source | NGINX Documentation. At first, everything is OK😇. Running sudo nginx -v returns the correct version of nginx.However, recently, when I ran the same command, it returned command not found:sudo nginx sudo: nginx: command not found nginx bash: nginx: command not foundEither sudo nginx or nginx gives the same result😣.Solution. To solve this problem, first you need to determine the path of your installed nginx. Your nginx may be contained in /usr/local/sbin or /usr/sbin. Once you find your nginx path, for instance, /usr/local/sbin/nginx, you can directly runsudo /usr/local/sbin/nginx -v nginx version: nginx/1.22.1This would output the version of nginx, which solves the problem.However, if you don't want to input the entire path of nginx everytime, you must add the path of nginx to the environment variables as follows.First, output the environment variables by running echo $PATH. You may found that the path of nginx is not in the output. Meanwhile, the output of the command which nginx is also void. Therefore, you need to check the file of environment variables:sudo vim /etc/profileIn /etc/profile, I found that /usr/local/sbin and /usr/sbin are in PATH only when I'm a root user. So we just need to add /usr/local/sbin or /usr/sbin to another PATH. For example:if [ $(id -u) -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/sbin:..." else PATH="/usr/local/sbin:/usr/local/sbin:..." fi export PATHAfter saving /etc/profile, reset the command linesource /etc/profileThen run nginx -v to check if it returns the correct version😄.nginx -v nginx version: nginx/1.22.1
2024-06-06 20:16:35

为什么有了uwsgi 还要 nginx 服务器?

有关nginx的简单介绍,详见Nginx服务器反向代理。uwsgi是python的一个通信协议,同时也是一种web服务器,而nginx则是高性能反向代理的web服务器。在Django项目服务器部署中,uwsgi几乎是不可替代的。然而部署好了uwsgi,其实django接口已经能够响应请求,为什么还要额外配置nginx服务器?因为,相比于直接将真实地址暴露在公网上,在外面套一层nginx安全性更高,具体如下:安全问题,程序不能直接被浏览器访问到,而是通过nginx,nginx只开放某个接口,uwsgi本身是内网接口,这样运维人员在nginx上加上安全性的限制,可以达到保护程序的作用。负载均衡问题,一个uwsgi很可能不够用,即使开了多个work也是不行,毕竟一台机器的cpu和内存都是有限的,有了nginx做代理,一个nginx可以代理多台uwsgi完成uwsgi的负载均衡。静态文件处理效率问题,用django或是uwsgi这种东西来负责静态文件的处理是很浪费的行为,而且他们本身对文件的处理也不如nginx好,所以整个静态文件的处理都直接由nginx完成,静态文件的访问完全不去经过uwsgi以及其后面的东西。这就是这几者之间的关系。
2024-05-15 00:06:04
Get connected with us on social networks! Twitter

©2024 Guangzhou Sinephony Technology Co., Ltd All Rights Reserved