Nginx的虚拟主机配置Vhost

软件开发大郭
0 评论
/
21 阅读
/
3005 字
29 2022-09
分类:

前端站点配置

server {
    listen       80;
    #listen       443 ssl;
    server_name  dev.seller.onesales.cn;
    # 域名,多个以空格分开
    #ssl_certificate     /usr/local/nginx/conf/cert/dev.seller.onesales.cn.pem;  # pem文件的路径
    #ssl_certificate_key  /usr/local/nginx/conf/cert/dev.seller.onesales.cn.key; # key文件的路径
    # ssl验证相关配置
    #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 utf8;
    access_log /var/log/nginx/seller_access.log;
    error_log  /var/log/nginx/seller_error.log;
    location / 
    {
        root         /app/system-seller/;
        index index.html index.htm;
        #解决跨域
        add_header Host $host;
        add_header X-Real-IP $remote_addr;
        add_header X-Real-PORT $remote_port;
        add_header X-Forwarded-For $proxy_add_x_forwarded_for;           
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.html?s=$1 last;
            break;
        }        
    }    

}

后端API配置

server {
    listen       80;
    #listen       443 ssl;
    server_name  dev.seller-api.onesales.cn;
    # 域名,多个以空格分开
    #ssl_certificate     /usr/local/nginx/conf/cert/seller-api.onesales.cn.pem;  # pem文件的路径
    #ssl_certificate_key  /usr/local/nginx/conf/cert/seller-api.onesales.cn.key; # key文件的路径
    # ssl验证相关配置
    #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 utf8;
    access_log /var/log/nginx/seller-api_access.log;
    error_log  /var/log/nginx/seller-api_error.log;
    location / {
        #解决跨域
        add_header Host $host;
        add_header X-Real-IP $remote_addr;
        add_header X-Real-PORT $remote_port;
        add_header X-Forwarded-For $proxy_add_x_forwarded_for;
        
        proxy_pass http://127.0.0.1:8889;
    }
}

GIT代码库配置

server {
    listen       80;
    #listen       443 ssl;
    server_name  git.devhost.work;
    # 域名,多个以空格分开
    #ssl_certificate     /usr/local/nginx/conf/cert/git.devhost.work.pem;  # pem文件的路径
    #ssl_certificate_key  /usr/local/nginx/conf/cert/git.devhost.work.key; # key文件的路径
    # ssl验证相关配置
    #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 utf8;
    access_log /var/log/nginx/git_access.log;
    error_log  /var/log/nginx/git_error.log;
    client_max_body_size 200m;
    location / {
        proxy_pass http://127.0.0.1:13000;
    }
}
    暂无数据