nginx

nginx配置文件在/etc/nginx/nginx.conf

配置文件:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user  root;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;

# Load dynamic module files from the /etc/nginx/conf.modules.d/ directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.modules.d/*.conf;

events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    #index   index.html index.htm;
    # another virtual host using mix of IP-, name-, and port-based configuration

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
    #    root         html;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #    }
    #}

    server {
        listen    443    ssl;    
        ssl_certificate   /root/anjianwei/domain.pem;
        ssl_certificate_key  /root/anjianwei/domain.key;
        server_name host.neroi.xyz;
        index       index.html index.html index.php;
        charset     utf-8;

        access_log  /var/log/nginx/ws.access.log;
        error_log  /var/log/nginx/ws.error.log;

        location /{
            proxy_redirect off;
            proxy_pass http://127.0.0.1:50065;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            }
        }
    
        server{
            listen 443;
            server_name neroi.xyz;
            charset utf-8;
            ssl on;
        
            ssl_certificate /home/an/domain/domain.pem;
            ssl_certificate_key /home/an/domain/domain.key;
                ssl_session_cache    shared:SSL:1m;
                ssl_session_timeout  5m;
            ssl_ciphers  HIGH:!aNULL:!MD5;
                ssl_prefer_server_ciphers  on;
            #error_page 497 https://$host:81$request_uri;

            keepalive_timeout 5;
            client_max_body_size 1G;
            access_log  /home/an/logs/nginx-access.log;
            error_log   /home/an/logs/nginx-error.log;

        location /static {
            alias /home/an/Django-BBS/assets;
            }

            location /media  {
            alias /home/an/Django-BBS/media;
            }
        location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:8989;
        }
    }
}

/etc/nginx/nginx.conf
/etc/nginx/nginx.conf

测试nginx:

nginx -t 

重启:

nginx -s reload

systemctl restart nginx.service

关闭nginx:

nginx  -s quit 

查询进程杀死

ps -ef | grep nginx

kill -9 port

--------------------------------              坑            -----------------------------------------

两个server不能使用同一个域名(但是可以使用不同的子域名)

 

 

443为HTTPS协议的端口

当使用HTTPS协议访问非80端口时,就不能再用HTTP协议了。能够支持两种协议共存的,只有80端口。

 
posted @ 2020-03-03 00:56  Neroi  阅读(152)  评论(0编辑  收藏  举报