nginx反向代理配置案例

  • 环境lnmp nginx 80端口 tomcat 8080端口
upstream rcservice {
    server 127.0.0.1:8080;
    #server 183.63.26.148:80;
}

server
{
    listen 80;
   server_name m.raycare.net;

    location /rcapi/ {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /rcweb/ {
        index index.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /rcadmin/ {
        index login.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /uploadfile/ {
        index login.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    access_log logs/rcweb.log;
}


server
{
listen 443 ssl http2;
     #listen [::]:443 ssl http2;
     server_name m.raycare.net ;
     index index.html index.htm index.php default.html default.htm default.php;
     ssl on;
     ssl_certificate /etc/letsencrypt/live/m.raycare.net/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/m.raycare.net/privkey.pem;
     ssl_session_timeout 5m;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_prefer_server_ciphers on;
     ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
     ssl_session_cache builtin:1000 shared:SSL:10m;
     # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
     ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

    location /rcapi/ {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /rcweb/ {
        index index.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /rcadmin/ {
        index login.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    location /uploadfile/ {
        index login.html;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://rcservice;
    }

    access_log logs/rcweb.log;
}

你可能感兴趣的:(nginx反向代理配置案例)