Skip to content

Instantly share code, notes, and snippets.

@weirenxue
weirenxue / port5000.cs
Created October 24, 2021 03:11
使 ASP.NET Core 應用程式開放 5000 Port,不只有 local 可以連線
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://*:5000").UseStartup<Startup>(); // 使用 UseUrls
});
@weirenxue
weirenxue / nginxrestart.sh
Created October 24, 2021 03:02
Restart Nginx service
[wrxue@localhost ~]$ sudo systemctl restart nginx # 重啟 nginx
@weirenxue
weirenxue / aspdotnetcorenginxconf.conf
Created October 24, 2021 03:00
ASP.NET Core 應用於 Nginx 的 configuration
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@weirenxue
weirenxue / movepublishfolder.sh
Created October 24, 2021 02:57
移動 Publish 資料夾
[wrxue@localhost ~]$ sudo mkdir -p /var/www/appName
[wrxue@localhost ~]$ sudo cp -R ./shares/publish/* /var/www/appName/
[wrxue@localhost ~]$ cd /var/www/appName/
[wrxue@localhost appName]$ dotnet appName.dll
@weirenxue
weirenxue / wincentsharefolder.sh
Created October 24, 2021 02:55
Windows 與 CentOS 設定 Share Folder
[wrxue@localhost ~]$ mkdir shares
[wrxue@localhost ~]$ sudo /usr/bin/vmhgfs-fuse .host:/Shared ~/shares -o subtype=vmhgfs-fuse,allow_other
@weirenxue
weirenxue / aspdotnetpublish.sh
Created October 24, 2021 02:54
Publish ASP.NET Core 應用程式
dotnet publish -c Release
@weirenxue
weirenxue / selinuxdisable.sh
Created October 24, 2021 02:50
Centos7 關閉 SELinux
[wrxue@localhost ~]$ sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/1' /etc/selinux/config
[wrxue@localhost ~]$ sudo reboot # 重開機
[wrxue@localhost ~]$ sudo sestatus # 查看 SELinux 的狀態,需為 disabled
@weirenxue
weirenxue / centos7firewall.sh
Last active October 24, 2021 02:51
CentOS7防火牆設定
[wrxue@localhost ~]$ sudo firewall-cmd --permanent --zone=public --add-port=5000/tcp # ASP.NET Core 應用程式預設的 Port
[wrxue@localhost ~]$ sudo firewall-cmd --permanent --zone=public --add-service=http
[wrxue@localhost ~]$ sudo firewall-cmd --reload
@weirenxue
weirenxue / nginxcentso7.sh
Last active October 24, 2021 02:51
在 CentOS7 上安裝 Nginx
[wrxue@localhost ~]$ sudo yum install -y epel-release
[wrxue@localhost ~]$ sudo yum install -y nginx
[wrxue@localhost ~]$ sudo systemctl start nginx
[wrxue@localhost ~]$ sudo systemctl enable nginx