So I have been trying to add script.js into my /var/www/html/ directory in a UBUNTU EC2 AWS Instance using VS Code Remote SSH extension. The directory has 777 permission yet when I save my file, the server stops responding and I can not connect to it through VS Code, terminal, nor the AWS CloudShell. I also can not access the public DNS to see my website anymore either.
I have the port 22 on 0.0.0.0 and all security groups correctly configured. The status checks all come back 2/2. I also have LAMP stack installed. Any ideas?
I never deployed any project before and I'm currently running with an issue while deploying a next.js app to godaddy. I uploaded my next.js app to the public_html folder of my cpanel and then i connected through ssh and executed the npm run dev command with server.js pointing to my domain name as hostname and 3000 as port number however, to access it i will have to write in the url www.mydomain.com:3000 . I learned that in order to access it by the following url www.mydomain.com I have to specify port 80 in the server.js file. However, when I do so and run the npm run dev command it says that I do not have the permission to port 0:0:0:0:80
Screenshot here
I have a VPS server and a domain name. I am doing something wrong or is there something I missed? Should I not use my domain name as hostname in the server.js file? Should I maybe keep the hostname as my VPS ip and port 3000 then point my domain to read from this address? I am a beginner with no previous exprience in deployement and this is my first next.js app ever.
Any help is appreciated and thank you!
Running the server and client on mac with localhost everything works fine.
Running the python program (server) on the raspberry pi and try to access it using its url doesn't work.
Python Server:
class Strompreisgenerator:
def __init__(self):
self.ws = websockets.serve(self.echo, 'localhost', 5001)
asyncio.get_event_loop().run_until_complete(self.ws)
asyncio.get_event_loop().run_forever()
async def echo(self, websocket, path):
async for message in websocket:
print(message)
Javascript Client:
var ws = new WebSocket("ws://www.tobiasschmocker.ch:5001");
While trying to instantiate the WebSocket the error "WebSocket network error: The operation couldn’t be completed. Connection refused" occurs in safari.
The Port 5001 is open on RPi. I also tried local IP. I forwarded the Port on my router but still nothing. If i trie other urls i get another error, so i suppose the url is correct but i have no rights somehow.
On my RPi i have ssh enabled, also php, apache, mysql and all the pip packages for my python server.
If you know, where the problem lies, i'd be happy to know. Thank you very much!
Now the websocket is running and available via url from external!
Following is the solution for completeness. All I had to do is:
Update to Python Version 3.6. The websockets package seems to work only from Python Version 3.6. Here's the tutorial I used to install Python 3.6 on my RPi: https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f
use 0.0.0.0 instead of localhost as host within python. On sudo netstat -lptu in the RPi terminal, I could see that all the other ports (mqtt, ssh, etc) where set to 0.0.0.0 instead of localhost so I just tried and it works.
Having set all that, the websocket is now running. Thanks to #YonatanKiron & #Reto!
I'm using this code to make an AJAX request:
$("#userBarSignup").click(function(){
$.get("C:/xampp/htdocs/webname/resources/templates/signup.php",
{/*params*/},
function(response){
$("#signup").html("TEST");
$("#signup").html(response);
},
"html");
But from the Google Chrome JavaScript console I keep receiving this error:
XMLHttpRequest cannot load
file:///C:/xampp/htdocs/webname/resources/templates/signup.php. Cross
origin requests are only supported for HTTP.
The problem is that the signup.php file is hosted on my local web server that's where all the website is run from so it's not cross-domain.
How can I solve this problem?
I've had luck starting chrome with the following switch:
--allow-file-access-from-files
On os x try (re-type the dashes if you copy paste):
open -a 'Google Chrome' --args -allow-file-access-from-files
On other *nix run (not tested)
google-chrome --allow-file-access-from-files
or on windows edit the properties of the chrome shortcut and add the switch, e.g.
C:\ ... \Application\chrome.exe --allow-file-access-from-files
to the end of the "target" path
If you’re working on a little front-end project and want to test it locally, you’d typically open it by pointing your local directory in the web browser, for instance entering file:///home/erick/mysuperproject/index.html in your URL bar. However, if your site is trying to load resources, even if they’re placed in your local directory, you might see warnings like this:
XMLHttpRequest cannot load file:///home/erick/mysuperproject/mylibrary.js. Cross origin requests are only supported for HTTP.
Chrome and other modern browsers have implemented security restrictions for Cross Origin Requests, which means that you cannot load anything through file:/// , you need to use http:// protocol at all times, even locally -due Same Origin policies. Simple as that, you’d need to mount a webserver to run your project there.
This is not the end of the world and there are many solutions out there, including the good old Apache (with VirtualHosts if you’re running several other projects), node.js with express, a Ruby server, etc. or simply modifying your browser settings.
However there’s a simpler and lightweight solution for the lazy ones. You can use Python’s SimpleHTTPServer. It comes already bundled with python so you don’t need to install or configure anything at all!
So cd to your project directory, for instance
1
cd /home/erick/mysuperproject
and then simply use
1
python -m SimpleHTTPServer
And that’s it, you’ll see this message in your terminal
1
Serving HTTP on 0.0.0.0 port 8000 ...
So now you can go back to your browser and visit http://0.0.0.0:8000 with all your directory files served there. You can configure the port and other things, just see the documentation. But this simply trick works for me when I’m in a rush to test a new library or work out a new idea.
EDIT:
In Python 3+, SimpleHTTPServer has been replaced with http.server. So In Python 3.3, for example, the following command is equivalent:
python -m http.server 8000
You need to actually run a webserver, and make the get request to a URI on that server, rather than making the get request to a file; e.g. change the line:
$.get("C:/xampp/htdocs/webname/resources/templates/signup.php",
to read something like:
$.get("http://localhost/resources/templates/signup.php",
and the initial request page needs to be made over http as well.
I was getting the same error while trying to load simply HTML files that used JSON data to populate the page, so I used used node.js and express to solve the problem. If you do not have node installed, you need to install node first.
Install express
npm install express
Create a server.js file in the root folder of your project, in my case one folder above the files I wanted to server
Put something like the following in the server.js file and read about this on the express gihub site:
var express = require('express');
var app = express();
var path = require('path');
// __dirname will use the current path from where you run this file
app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, '/FOLDERTOHTMLFILESTOSERVER')));
app.listen(8000);
console.log('Listening on port 8000');
After you've saved server.js, you can run the server using:
node server.js
Go to http://localhost:8000/FILENAME and you should see the HTML file you were trying to load
If you have nodejs installed, you can download and install the server using command line:
npm install -g http-server
Change directories to the directory where you want to serve files from:
$ cd ~/projects/angular/current_project
Run the server:
$ http-server
which will produce the message Starting up http-server, serving on:
Available on:
http://your_ip:8080 and
http://127.0.0.1:8080
That allows you to use urls in your browser like
http://your_ip:8080/index.html
It works best this way. Make sure that both files are on the server. When calling the html page, make use of the web address like: http:://localhost/myhtmlfile.html, and not, C::///users/myhtmlfile.html. Make usre as well that the url passed to the json is a web address as denoted below:
$(function(){
$('#typeahead').typeahead({
source: function(query, process){
$.ajax({
url: 'http://localhost:2222/bootstrap/source.php',
type: 'POST',
data: 'query=' +query,
dataType: 'JSON',
async: true,
success: function(data){
process(data);
}
});
}
});
});
REM kill all existing instance of chrome
taskkill /F /IM chrome.exe /T
REM directory path where chrome.exe is located
set chromeLocation="C:\Program Files (x86)\Google\Chrome\Application"
cd %chromeLocation%
cd c:
start chrome.exe --allow-file-access-from-files
change chromeLocation path with yours.
save above as .bat file.
drag drop you file on the batch file you created. (chrome does give restore pages
option though so if you have pages open just hit restore and it will work).
You can also start a server without python using php interpreter.
E.g:
cd /your/path/to/website/root
php -S localhost:8000
This can be useful if you want an alternative to npm, as php utility comes preinstalled on some OS' (including Mac).
For all python users:
Simply go to your destination folder in the terminal.
cd projectFoder
then start HTTP server
For Python3+:
python -m http.server 8000
Serving HTTP on :: port 8000 (http://[::]:8000/) ...
go to your link: http://0.0.0.0:8000/
Enjoy :)
There are some problems about Scrumblr(GPL Web Application).
Scrumblr consist of Node.js and Redis.
This is Github url : https://github.com/aliasaria/scrumblr .
I run "scrumblr" at localhost:8080 on Ubuntu 11.10.
I configured global IP address on my Ubuntu.
However, I can't access Scrumblr when I accessed "http://global IP address:8080/".
(Error message: Can't establish a connection to the server )
How should I modify scrumblr's source code?
So, please tell me place(directory, file)where I should modify to access Scrumblr via "http://global IP address:8080/".
What I usually do is open up the port 8080 in my firewall so I CAN access it externally, then server the app with localhost:8080 -- sometimes you may have to bind that to an ip, but I'm not sure. I use express which basically takes care of that for me.
Then I edit my /etc/hosts file and map foo.myapp to my public ip address...then I can browse to http://foo.myapp:8080 from anywhere.