查看nginx所在的路径
[root@webteam local]# ps -ef | grep nginx
root 1652 1 0 5月04 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 1653 1652 0 5月04 ? 00:00:01 nginx: worker process
ascs 6181 2267 0 17:19 ? 00:00:04 node /usr/share/nginx/html/citymakerTools/bin/www
root 6408 6387 0 22:28 pts/2 00:00:00 grep --color=auto nginx
[root@webteam local]# cd /etc/nginx/
nginx服务启动、关闭、重启:
service nginx start
service nginx restart
service nginx stop
nginx配置默认首页
location / {
root /usr/share/nginx/html/;
index index.html index.htm hubpage/index.html;
}
nginx配置反向代理
location /baoan-platform/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host test.cityworks.cn;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://test.cityworks.cn/;
}
在nginx的配置文件
server {
listen 80;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /iot/api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://10.10.1.211:8888/;
}
location /baoan-platform/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host test.cityworks.cn;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://test.cityworks.cn/;
}
location / {
root /usr/share/nginx/html/;
index index.html index.htm hubpage/index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
解决window中文文件名上传到linux的nginx服务乱码
1:确定你的系统是UTF编码
[root@Tserver ~]# env|grep LANG
LANG=en_US.UTF-8
2:NGINX配置文件里默认编码设置为utf-8
server
{
listen 80;
server_name .inginx.com ;
index index.html index.htm index.php;
root /usr/local/nginx/html/inginx.com;
charset utf-8;
}
如果是用securecrt 上传文件,请选择 会话–>外观–UTF-8
如果是FTP软件也将默认编码设置为TUF-8
3、将非UTF-8的文件名转换为UTF-8编码
使用nginx的优点在于能够使用中文url,但是Windows的文件名中文编码默认为GBK,拿过来需要转换
做法很简单,把文件名都修改成utf8编码就可以了! 【但apache是不需要这么麻烦的】
安装convmv,由他去转换编码:
//从指定源拉取软件
yum install nginx --enablerepo=epel
convmv -f GBK -t UTF8 -r --notest target 目标路径
其中-f是源编码,
-t是目标编码,
-r是递归处理目录,
–notest是不移动,实际上对文件进行改名,
target是目标目录,如果本身就在当前目录下,可以使用./
在对于windows操作系统的时候,可以无视此方法,一般windows下使用nginx转发的时候是不会出现这类问题的,当先的方法只是针对的是linux下的操作。