本文摘自PHP中文网,作者(*-*)浩,侵删。
配置nginx的方法:首先要打开“/etc/nginx/conf.d/”文件夹;然后创建配置文件;接着在“/etc/nginx/nginx.conf”文件中修改配置项;最后重新启动nginx即可。

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器
Nginx (engine x) 也是一个高性能的HTTP和反向代理服务,也是一个IMAP/POP3/SMTP服务。Nginx是由伊戈尔?赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的 (推荐学习:nginx教程)
前后端nginx配置
1.打开 /etc/nginx/conf.d/文件夹,创建配置文件xxx.conf,内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | server {
listen 80;
server_name **.106.2**.175;
location / {
root /public/app/dist;
index index.php index.html index.htm;
}
location /sell {
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-NginX-Proxy true;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}}
|
在 /etc/nginx/nginx.conf文件中有一行就是把刚刚配置的引进总的nginx配置中
1 2 | ...
include /etc/nginx/conf.d/*.conf;...
|
3.配置完成后重新启动nginx
1 2 3 4 | nginx -t # 查看nginx状态
nginx -s reload # 重新载入配置文件
nginx -s reopen # 重启 Nginx
nginx -s stop # 停止 Nginx
|
配置https
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | server {
listen 443;
server_name xx.name.com;
ssl on;
index index.html index.htm;
ssl_certificate cert/215079423330181.cert;
ssl_certificate_key cert/215079423330181.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root / public /app/dist;
index index.php index.html index.htm;
}
location /sell {
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-NginX-Proxy true;
proxy_pass http:
proxy_redirect off;
}
}
|
nginx.conf 默认文件
阅读剩余部分
相关阅读 >>
利用yum安装nginx服务
nginx配置文件详解
nginx中必须配置的参数介绍
网页出现nginx什么意思
阿里云服务器端口怎么开放
nginx如何配置反向代理
细说nginx的内置变量
nginx常见错误及解决方法介绍
nginx四层负载均衡配置
英文nginx是什么意思
更多相关阅读请进入《nginx》频道 >>
转载请注明出处:木庄网络博客 » nginx怎么配置