• nginx 反响代理配置asp.net core


    appsetting.json

    {
      "ConnectionStrings": {
        "MF.MySQl.ApplicationDB": "zGuqeG3rtm5+bP7XT2PqIc8MNT7U/ZAuSSrrJr/ReZngB1gPt5GRPGHSppS/zBCGufabxLoVs5ZHfxYe3zpxBRx15esc8rSsqgTj8kXUg4WA+s1u4DJW0LzHy3Hd3mwbl1zCa09ucNxlkHmRKYP/aQ=="
      },
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "Kestrel": {
        "EndPoints": {
          "Http": {
            "Url": "https://0.0.0.0:5000" // 端口自己改吧
          }
        }
      },
      "AllowedHosts": "*"
    }
    
    

    配置服务(asp.net)

    配置代码如下(保存为xxx.server)

    [Unit]
    Description=MicroFeel.ids4.server
    After=network-online.target
     
    [Service]
    Type=simple
    User=root
    WorkingDirectory=/home/wwwroot
    ExecStart=/home/wwwroot/Sugar.IdServer4
    Restart=always
     
    [Install]
    WantedBy=multi-user.target
    

    在服务器上运行

    # xxx就是上面配置代码的文件名称
     sudo systemctl enable xxx
     sudo systemctl start xxx
    

    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 nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/doc/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_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # 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;
    
         #设定虚拟主机配置
    	server {
    	 #侦听443端口,这个是ssl访问端口
    	 listen 443;
    	 #定义使用 访问域名
    	 server_name ids4.microfeel.net;
    	 #定义服务器的默认网站根目录位置
    	 root /home/wwwroot; 
    	  
    	 
    	 # 这些都是腾讯云推荐的配置,直接拿来用就行了,只是修改证书的路径,注意这些路径是相对于/etc/nginx/nginx.conf文件位置
    	 ssl on;
    	 ssl_certificate /etc/nginx/ids4.microfeel.net_chain.crt;
    	 ssl_certificate_key /etc/nginx/ids4.microfeel.net_key.key;
    	 ssl_session_timeout 5m;
    	 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
    	 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
    	 ssl_prefer_server_ciphers on;
    	 
    	 #默认请求
    	 location / { 
    		proxy_pass http://localhost:5000;  #把80端口的访问反向代理到5000端口(你程序的启动端口),请根据实际情况修改自己的端口
            	proxy_http_version 1.1;
            	proxy_set_header Upgrade $http_upgrade;
            	proxy_set_header Connection keep-alive;
            	proxy_set_header Host $http_host;
            	proxy_cache_bypass $http_upgrade;	
    	 }
    	 
    	 #静态文件,nginx自己处理
    	 location ~ ^/(images|javascript|js|css|flash|media|static)/ {
    	 #过期30天,静态文件不怎么更新,过期可以设大一点,
    	 #如果频繁更新,则可以设置得小一点。
    	 expires 30d;
    	 }
    	 
    	 #禁止访问 .htxxx 文件
    	 # location ~ /.ht {
    	 # deny all;
    	 #}
    	 
    	} 
    }
    
    

    写在最后

    可以通过vs发布成linxu x64 或者是ram,如果是windows服务器那就生成windows的。这样可以避免在linux下配置.netcore环境

  • 相关阅读:
    ExtJs系列教程
    linux 服务器时间 timedatectl命令时间时区操作详解
    aws CloudWatch Events
    AWS Shield
    aws ssm指令
    failed to set bridge addr: "cni0" already has an IP address different from 10.244.0.1/24
    AWS Systems Manager
    Amazon Inspector
    AWS 安全培训
    Amazon Inspector
  • 原文地址:https://www.cnblogs.com/xiaoch/p/13417929.html
Copyright © 2020-2023  润新知