ubuntu14.04 nginx配置

1,默认安装nginx

sudo apt-get install nginx

如果找不到就sudo apt-get update一下

2,进入nginx配置目录

cd /etc/nginx

3,创建自己项目的nginx配置文件

cd nginx.d
touch aaa.conf

4,配置自己项目的代理

upstream imdou8{
  server localhost:8000;
}

server{
   listen 80;
   server_name 104.128.**.**;
   location / {
     proxy_pass http://imdou8;
   }
}
server{
   listen 80;
   server_name www.imdou8.com;
   location / {
     proxy_pass http://imdou8;
   }
}

5,重启nginx

/etc/init.d/nginx restart


配置https

1,生成自认证证书

openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl rsa -in server.key -out server_nopwd.key
openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt


server {
    listen 443;
    server_name  www.imdou8.com;
    ssl                  on;
    ssl_certificate       /etc/nginx/conf.d/ssl/server.crt;
    ssl_certificate_key   /etc/nginx/conf.d/ssl/server.key;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    location / {
       proxy_set_header Host $http_host;
       proxy_pass http://imdou8;
    }
}

http跳转到https

server{
   listen 80;
   server_name www.imdou8.com;
#   location / {
#     proxy_pass http://imdou8;
#   }
   rewrite ^(.*)$  https://$host$1 permanent;
}

================================邪恶的分割线==============================

总体静态网站配置

#upstream imdou8{
#  server localhost:8000; 
#} 

server{
   listen 80;
   server_name 104.128.81.91;
   rewrite ^(.*)$  https://$host$1 permanent;
}

server{
   listen 80;
   server_name imdou8.com;
   rewrite ^(.*)$  https://$host$1 permanent;
}

server{
   listen 80;
   server_name www.imdou8.com;
#   location / {
#     proxy_pass http://imdou8;
#   }
   rewrite ^(.*)$  https://$host$1 permanent;
}

server {
    listen 443;
    server_name  www.imdou8.com;
    ssl                  on;
    ssl_certificate       /etc/nginx/conf.d/ssl/server.crt;
    ssl_certificate_key   /etc/nginx/conf.d/ssl/server.key;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    root index.html;
    location / {
        proxy_set_header Host $http_host;
        alias /usr/share/website/imdou8/admin/src/;
        expires 1d;
    }
 #   location / {
 #      proxy_set_header Host $http_host;
 #      proxy_pass http://imdou8;
                                                                                                                         8,1           Top






 
  

你可能感兴趣的:(远程服务器部署)