I am new to Nginx and have been trying to set up server blocks in Nginx, locally on macOS. The purpose is to render Nuxt app when a user requests a certain domain. However, even after spending hours and hours on it, I am not able to identify why I can not hit the domain (here example1256.com) and get the nuxt app content in return.
This is my nginx.conf
etc/hosts (which btw I created myself, hosts file was not there from installation)
directory structure
If I try doing 127.0.0.1:8080, I get the Nuxt content in return. However, hitting the domain always yeilds this:browser: chrome
Related
I'm building a Flask/Apache2 web app that includes large video files that a user must be authenticated to view. I'd like to use Flask to serve the video files after authentication and not having to expose the media directory instead of just the plain HTML video tag that anyone with the URL can access.
I've tried using flask's send_file which works for things like images and thumbnails but large videos take forever to buffer and freeze up.
I see that NGINX has X-Accel-Redirect for the redirection of video files on my server (hidden, not in the web directory) to go to the user through flask but I'm not that sure how to implement this with Apache2.
Running Flask, Apache2, Ubuntu
TLDR:
Basically trying to send large files to the user through flask (not using send_file as this freezes) to enable authentication and not having to expose the whole directory to the internet with the files as I would with the video HTML tag. NGINX has X-Accel-Redirect, what's the apache2 equivalent for use in flask?
Thanks!
OK, so a little background on the environment configuration at present:
Using VS2017
IISExpress folder present in my documents folder with applicationhost.config file
When I run my web project in VS2017, it runs successfully through IISExpress. If I view the IISExpress config window then it shows me that my app is running successfully and that it's using the config from my source\repos folder and not the main IISExpress folder in my documents. If I look at the config file in the IISExpress folder there is no mention of the bindings for my currently running application (makes sense, as it apparently uses a different config file).
However, within my app I need to be able to use the Microsoft.Web.Administration toolset to try and identify the port bound to https for the current site to handle a redirect to a page that must be secure. In the production environment this is just handled by pushing to https:// because we know an SSL certificate will be present. But, when debugging locally I need to switch to SSL and take the port number otherwise my redirect is broken, for obvious reasons.
Using _Manager_ServerManager As New ServerManager
For Each _Loop_Binding As Binding In _Manager_ServerManager.Sites(System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName()).Bindings
If (_Loop_Binding.IsIPPortHostBinding) AndAlso (_Loop_Binding.Protocol.ToLower() = "https") Then Return _Loop_Binding.EndPoint.Port
Next
End Using
The code above causes an error when running, as the current site does not exist within _Manager_ServerManager.Sites. If I inspect this property then I can only see the applications that are configured in the configuration file taken from the IISExpress folder in my documents, not the current site!
I'm really scratching my head on this one, is there any way programmatically that I can get this information for the currently running website?!
EDIT
Based on some of the comments below, more clarity has been requested as to what I'm actually trying to achieve. The website typically operates on standard HTTP, however, when progressing to one particular page for security reasons we need to shift to HTTPS:
Response.Redirect("https://" & Request.Url.DnsSafeHost & "/my-page.aspx")
When debugging this website locally, using IISExpress, this results in you being redirected to https://localhost/my-page.aspx, which is incorrect because the site runs on a port of localhost (i.e. http://localhost:64905 and https://localhost:64906). This means that I cannot just append Request.Url.Port onto the end of DnsSafeHost, because it will not be the HTTPS port required. Thus, so that we can run this project locally on our dev machines we need to automatically switch the port to the HTTPS version so that we can continue seamlessly without any disruption and having to manually rebuild the URL each time we get redirected.
This is my first attempt to migrate a project from Cloud9 to AWS Cloud9 since the clock is ticking.
I have created a brand new environment on AWS Cloud9, which is supposed to work out of the box. I've uploaded WordPress files and database, replaced URLs with my environment's preview URL (https://*.vfs.cloud9.eu-west-1.amazonaws.com), then ran the build with a PHP (built-in web server) runner.
Usually, that's all that is needed to migrate a WordPress website but this time I am stuck in a redirection loop whenever I try to preview the site.
My findings so far are that it's all down to forced SSL by AWS Cloud9. They specifically said they won't allow for any environment to work over a non-secure connection.
When I set the home_url in the options table to "http://...", then the loop breaks and the site appears. Of course, assets don't load because of the insecure connection. However, when I switch back to https in the home_url value, I am back in the loop...
No matter what I put in .htaccess, it doesn't help. I can't even find where to config Apache as the default /etc/httpd/conf.d/httpd.conf refers to /var/www directory, where as AWS C9's default workspace dir is /home/ec2-user/environment.
Below is a screenshot of my console while it's stuck in the loop. It does numerous connection to itself (duh..) and finally terminates.
I am trying to redirect my meteor app (hosted by heroku) to www with https on. So:
https://exampledomain.com -> https://www.exampledomain.com
Is there a way to do this either in Heroku or the Meteor application itself? Thank you.
Meteor by itself cannot do redirects and does not support https.
Heroku is a hosting service, and will host whatever compatible application you give it, on top of it's Cedar stack, which is basically an Ubuntu OS. It does not even know that your app will be using http. So the Heroku environment will not help you either.
What you need to do is build an Heroku app consisting of your Meteor app and a HTTP Reverse Proxy in front of it, which handles the redirect you are asking for, and also the https. This proxy terminates the https connections coming from the Internet, and serves them as http to your Meteor app behind it.
The easiest proxy to set up is Nginx, although HAProxy also works well.
Have a look at for example Have you managed to make your node nginx proxy setup on Heroku work? for how to set this up.
I am using PHP (5.3) to upload jpeg files, create folders for those files and store them. I have a development version and a live version both running on the same server (CentOS 7, Apache, Plesk 12).
On the live version, I am experiencing no problems, but on the dev version, the files are uploading successfully but I am getting nginx 404 errors when trying to access them through the browser.
If I try to access something which doesn't exist, I get a standard 404 error (not an nginx one).
When checking the access_log, I see a 200 code for the files.
Nothing in the error_log nor in the nginx error log.
No differences in PHP code, folder structure or configuration.
I recently changed servers and this is the first time I have attempted this upload on the dev system on this new server. Live version is used daily for this activity.
If I try to access older uploads on the dev server, they all work fine. It is only affecting new uploads.
Permissions and ownership are the same for both live and dev systems and old/new folders/files.
If I manually upload a jpeg to the folder, it also triggers an nginx 404 when accessed.
I have no experience with nginx so I am at a loss as to what I can try to resolve this issue.
It looks like you have upload and access files in one place but checking log in another place.
Are you sure you have no issues with domain name resolving?
Also it can be issue with virtual host - when you access file it overtaken by some other virtual host. It maybe default host for IP address.
I recommend you grep all system and vhost logs for file you have trying to access.