安装nginx

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装nginx相关的知识,希望对你有一定的参考价值。

nginx 不仅可以做反向代理,也可以做正向代理(代理上网)
http://nginx.org/en/download.html
./configure --prefix=/home/nginx --with-pcre --with-http_ssl_module(https)
配置https

nginx 阿里云
    server {
    listen 6301;
    server_name xxxxxxx;
    ssl on;

    ssl_certificate   cert/xxxxxx.pem;
    ssl_certificate_key  cert/xxxxxx.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 /home/nginx/xxx;
                  try_files $uri /index.html;
                  expires       max;

             }
        }

nginx.conf

#user  nobody;
worker_processes  8;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  /usr/local/ngin/logs/error.log  info;

pid        /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 65535;
events {
    worker_connections  65535;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
    #                  ‘$status $body_bytes_sent "$http_referer" ‘
    #                  ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    upstream tomcat {
         #ip_hash;
             server xxx:8200;
             server xxx:8201;
    }

    #gzip  on;

    server {
        listen       8180;
        server_name xxxxx;
        ssl on;

        ssl_certificate   /usr/local/nginx/cert/xxxx.pem;
        ssl_certificate_key /usr/local/nginx/cert/xxxxxx.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;
            #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location ^~ /txserver/ {
            proxy_pass http://tomcat;

        }
        location / {
             root /usr/local/nginx/xxx;
             try_files $uri /index.html;
              expires       max;

        }

        #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   html;
        }

}

以上是关于安装nginx的主要内容,如果未能解决你的问题,请参考以下文章

nginx.conf 忽略了 nginx-ingress 配置映射片段

将 nginx rtmp 片段发送到 WebRTC

text 有用的nginx命令和片段

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

linux学习:Nginx--常见功能配置片段与优化-06

PHP代码-psysh调试代码片段工具