beego deploy the project to nginx (including http turn https)

beego deploy the project to nginx (including http turn https)

   Prior to deploying the deployment server directly employed, convenient, Nginx now to deploy it, so that subsequent reverse proxy and load balancing, while, due to the small micro-channel access procedure, it is necessary to previously domain http: / /www.xxxxxx.com turn into https://www.xxxxxx.com.
More may be concerned about the public number, which are the original author.

1, install Nginx.       

   Uninstall the original nginx: sudo apt-get -purge autoremove nginx

    安装nginx:sudo apt-get install nginx

    Figure:

   

 

2, deployment beego to nginx, increase ssl certificate (certificate application to be registered account Tencent cloud applications now have free use of one-year certificate).

Modify /etc/nginx/nginx.conf. You can also add files in the conf directory /etc/nginx/conf.d/ to configure specific to a service. Configured here is /etc/nginx/nginx.conf.

user www-data;
worker_processes auto;
pid /run/nginx.pid;


events {
  worker_connections 768;
  # multi_accept on;
}


http {


  ##
  # Basic Settings
  ##


  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  # server_tokens off;


  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;


  include /etc/nginx/mime.types;
  default_type application/octet-stream;


  ##
  # SSL Settings
  ##


  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;


  ##
  # Logging Settings
  ##


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


  ##
  # Gzip Settings
  ##


  gzip on;
  gzip_disable "msie6";


  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


  ##
  # Virtual Host Configs
  ##


  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;


  server {
           80 the listen; 
          server_name www.XXXXXX.com; # Your name 


          # configure HTTPS 
          ssl ON; 
          ssl_certificate 1_XXXXXX.com_bundle.crt; ssl certificate nginx # your application in 
          ssl_certificate_key 2_XXXXXX.com.key; # nginx your application in Key 
          ssl_session_timeout 5m; 
          ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
          ssl_ciphers to the RSA-ECDHE-the AES128-GCM-the SHA256:! HIGH: aNULL: the MD5: the RC4: of DHE;!!! 
          ssl_prefer_server_ciphers ON; 




        charset UTF-. 8; 
        access_log / Home / ubuntu / beego / access.log; # this directory is recommended that you deploy the file directory 


        LOCATION / (CSS | JS | Fonts | img) / { 
            access_log OFF; 
            the Expires 1D;

 
            root "/ Home / Ubuntu / beego / static"; # this file is a static file path to your static beego project 
          try_files $ uri @backend; 
        } 


        LOCATION / { 
            try_files / _not_exists_ @backend; 
        } 


        LOCATION @backend { 
            proxy_set_header-the X-Forwarded $ REMOTE_ADDR -for; 
            proxy_set_header Host $ HTTP_HOST; 


            proxy_pass http://127.0.0.1:8999; # proxy address pointed to beego project 
        } 
  } 
} 




#mail { 
# # See the Sample Script AT authentication: 
# # HTTP: // Wiki. nginx.org/ImapAuthenticateWithApachePhpScript 
# 
# # auth_http localhost / auth.php; 
# # pop3_capabilities "TOP" "the USER";
#  # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#  server {
#    listen     localhost:110;
#    protocol   pop3;
#    proxy      on;
#  }
# 
#  server {
#    listen     localhost:143;
#    protocol   imap;
#    proxy      on;
#  }
#}
3, nginx load configuration, service nginx start
        Load configuration: sudo nginx -s reload
        start nginx: nginx restart sudo Service
4, start beego service. verification.
       
        The agency now has 80 to 8999 ports beego project.

 

Guess you like

Origin www.cnblogs.com/shanchen/p/11725799.html