nginx怎么配置


本文摘自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://127.0.0.1:8080;

            proxy_redirect off;

        }

   }

nginx.conf 默认文件

阅读剩余部分

相关阅读 >>

nginx如何隐藏后缀名php

tengine和nginx哪个好

nginx日志数据如何实时监控

nginx怎么打开

nginx可以启动成功却无法访问

系统提示找不到nginx命令怎么办

nginx和lvs区别

nginx如何配置反向代理

使用nginx有什么优点

linux服务器如何安装nginx

更多相关阅读请进入《nginx》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...