使用WinSCP上傳文件到指定服務器並配置nginx


安裝WinSCP

首先,我們先去官網下載 WinSCP,點擊下圖所示的下載即可。

新建站點

打開 WinSCP,系統自動要求新建站點登錄。
文件協議選擇 SFTP,主機名填入自己服務器的公網ip,端口號選擇 22。用戶名和密碼填入自己登入服務器的用戶名和密碼。填寫完畢之后,點擊登錄。

登錄完成之后,可以看到界面分成了左右兩側。左側界面是控制自己電腦文件的,右側界面是控制自己服務器文件的。

傳輸文件

比如上傳vue打包文件,我們再左側本地目錄內找到打包之后的dist文件夾,右側打開需要放打包文件的文件夾。

第一步

第二步

配置nginx

但是呢,我們是上傳到服務器了,但是我們還需要配置一下nginx轉發才可以公網進行訪問
我們在右側界面找到服務器上nginx的安裝位置,比如我的在/etc/nginx文件下

實現公網訪問

點開nginx.conf,進行編輯

主要操作

現在我們去登錄我們的服務器,找到 nginx安裝的所在文件夾,點擊下圖箭頭指示的位置,打開對話窗口

重啟nginx

./nginx -s reload

查看項目

這個時候我們打開瀏覽器,輸入自己服務器的 ip 地址,就可以訪問到我們上傳的vue項目了。

域名轉發ip

阿里雲后台連接起來,nginx配置
之前配置完整版(僅供參考)

內蒙測試服務器

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/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;
        client_max_body_size    20m;
    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 {
         listen       81;
         server_name  localhost;

        

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                      root   /app/frontcode;
                      index  index.html index.htm;
        }
        location /NMPWgcgk/ {
            proxy_pass  http://47.104.17.68:8081/NMPWgcgkV1.0.4/;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
    
     server {
         listen       85;
         server_name  localhost;

        

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                      root   /app/hrsys/frontcode;
                      index  index.html index.htm;
        }
        location /api/ {
            proxy_pass  http://47.104.17.68:9091/hrsys/;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
    
    server {
        listen       82;
        server_name  localhost;
        
        location / {
            root   /app;
            index  index.html index.htm;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

       server {
        listen       80;
        server_name  www.tyjsta.com tyjsta.com;
        
        location / {
            proxy_pass  http://127.0.0.1:82/tyj/;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

      server {
        listen       80;
        server_name  www.kesust.com kesust.com;
        
        location / {
            root   /app/kesu;
            index  index.html index.htm;
            proxy_pass http://127.0.0.1:82/kesu/;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

    server {
        listen       80;
        server_name  www.drzlst.com drzlst.com;
        
        location / {
            root   /app/kesu;
            index  index.html index.htm;
            proxy_pass http://127.0.0.1:82/dairui/;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

     server {
        listen       80;
        server_name  www.qishst.com qishst.com;
        
        location / {
            root   /app/lwwb;
            index  index.html index.htm;
            proxy_pass http://127.0.0.1:82/lwwb/;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
        server {
        listen       84;
        server_name  localhost;
        
        location / {
            root   /app/lwwb;
            index  index.html index.htm;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }








# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}


服務器中的nginx

   #cd /tmp/nginx    //進入當前nginx文件夾
   #rpm -Uvh *.rpm    // 解壓 壓縮包
   #iptables -I INPUT -p tcp --dport 80 -j ACCEPT   //添加防火牆
   #service iptables save     //保存
   #service iptables restart   //重啟
   #chkconfig nginx on     
   #service nginx restart   //重啟nginx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM