所以我在我的虚拟服务器(virtualbox)上安装了Nginx,Node.js和C#ASP.NET Core 2.1,并且当前在每个单独的端口上运行.
Node.js在localhost:3000上运行.
.NET Core在localhost:5000上运行.
但后来我想在这种情况下制作自定义URI.如果用户访问根站点(仅"/"),则它将转到Node.js应用程序.如果用户访问另一个页面(在这种情况下,如果用户访问"/ api"),那么我希望用户进入.NET Core应用程序.
现在,如果我访问根网站,它可以正常工作.我访问192.168.56.2(这是我的虚拟服务器IP)的示例,然后浏览器将打开Node.js应用程序.但是,如果我访问192.168.56.2/api,它将返回404错误代码.
这是我的/etc/nginx/sites-available/default配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm;
root /var/www/html;
server_name _;
# Front-end : Node.js
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Back-end : C# ASP.NET Core 2.1
location /api/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade …Run Code Online (Sandbox Code Playgroud) 我有CodeIgniter控制器文件,放在这里
controllers/public/Pubweb.php
Run Code Online (Sandbox Code Playgroud)
我想将该文件设置为我的默认控制器,但是当我更改默认控制器路由值时,它将出错.我的路线代码:
$route['default_controller'] = 'public/pubweb';
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗?
我有很多无线电元素,它们具有不同的名称和值。当我单击收音机时,它将通过AJAX方法发送到服务器。
AJAX方法:
$("input[type=radio]").click(function() {
$.ajax({
url: "http://localhost/myproject/ajax_url",
type: "POST",
data: $("#my-form").serialize(),
dataType: JSON,
success: function(){}
});
});
Run Code Online (Sandbox Code Playgroud)
以前,我使用的是jQuery 2.2.4版,它可以正常工作,但是当我尝试使用jQuery 3.1.1版对其进行更改时,它显示了一个错误:
未捕获的TypeError:(o.dataType ||“ *”)。toLowerCase不是函数
我确定我在服务器上键入的内容没有错(因为我从未更改过服务器代码),该错误仅在尝试升级jQuery版本时显示。您的解决方案可能对我有很大帮助:)
.net-core ×1
ajax ×1
asp.net-core ×1
c# ×1
codeigniter ×1
javascript ×1
jquery ×1
nginx ×1
node.js ×1
php ×1
routes ×1