Nginx配置使用詳解

配置步驟:
1、配置nginx的方法:首先要打開“/etc/nginx/conf.d/”文件夾;
2、然后創(chuàng)建配置文件;接著在“/etc/nginx/nginx.conf”文件中修改配置項;
3、最后重新啟動nginx即可
Nginx是一款輕量級的Web 服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器
Nginx (engine x) 也是一個高性能的HTTP和反向代理服務(wù),也是一個IMAP/POP3/SMTP服務(wù)。Nginx是由伊戈爾·賽索耶夫為俄羅斯訪問量第二的Rambler.ru站點(俄文:Рамблер)開發(fā)的 (推薦學(xué)習(xí):nginx教程)
前后端nginx配置
1.打開 /etc/nginx/conf.d/文件夾,創(chuàng)建配置文件xxx.conf,內(nèi)容如下:
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;
}}2.在 /etc/nginx/nginx.conf文件中有一行就是把剛剛配置的引進(jìn)總的nginx配置中
...
include /etc/nginx/conf.d/*.conf;...3.配置完成后重新啟動nginx
nginx -t # 查看nginx狀態(tài) nginx -s reload # 重新載入配置文件 nginx -s reopen # 重啟 Nginx nginx -s stop # 停止 Nginx
4.配置https
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://127.0.0.1:8080;
proxy_redirect off;
}
}5.nginx.conf 默認(rèn)文件
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_age
以上就是nginx怎么配置的詳細(xì)內(nèi)容!
到此這篇關(guān)于Nginx配置使用的文章就介紹到這了。希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信